3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/arjdbc/cassandra/connection_methods.rb', line 3
def cassandra_connection(config)
begin
require 'jdbc/cassandra'
::Jdbc::Cassandra.load_driver(:require) if defined?(::Jdbc::Cassandra.load_driver)
rescue LoadError end
config[:host] ||= '127.0.0.1'
config[:port] ||= 9160
config[:url] ||= "jdbc:cassandra://#{config[:host]}:#{config[:port]}/#{config[:database]}"
config[:driver] ||= defined?(::Jdbc::Cassandra.driver_name) ? ::Jdbc::Cassandra.driver_name : 'org.apache.cassandra.cql.jdbc.CassandraDriver'
config[:adapter_class] = ActiveRecord::ConnectionAdapters::CassandraAdapter
config[:adapter_spec] = ::ArJdbc::Cassandra
options = (config[:options] ||= {})
jdbc_connection(config)
end
|