Class: Cassanity::Client
- Inherits:
-
Object
- Object
- Cassanity::Client
- Extended by:
- Forwardable
- Defined in:
- lib/cassanity/client.rb
Constant Summary collapse
- DelegateToConnectionMethods =
Methods on client that should be delegated to connection.
[ :keyspaces, :keyspace, :[], :batch, ]
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Public: The instance of the Cassanity::Connection that is the entry point for all operations.
-
#driver ⇒ Object
readonly
Public: The instance of the Cql::Client being used.
-
#executor ⇒ Object
readonly
Public: The instance of the Cassanity::Executors::CqlRb that will execute all queries.
Instance Method Summary collapse
-
#connect ⇒ Object
Reconnect to cassandra.
- #connected? ⇒ Boolean
-
#disconnect ⇒ Object
Disconnect from cassandra.
-
#initialize(servers = nil, port = nil, options = {}) ⇒ Client
constructor
Public: Initialize an instance of the client.
-
#inspect ⇒ Object
Public.
Constructor Details
#initialize(servers = nil, port = nil, options = {}) ⇒ Client
Public: Initialize an instance of the client.
servers - The String or Array of Strings representing the servers to
connect to.
port - The Integer representing the port to connect to Cassandra with.
This must be the same for all hosts.
options - The Hash of Cql::Client options.
:default_consistency - default consistency for the connection
(if not specified, set to :quorum)
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/cassanity/client.rb', line 31 def initialize(servers = nil, port = nil, = {}) servers ||= ['127.0.0.1'] port ||= 9042 @options = .merge(hosts: servers, port: port) @instrumenter = @options.delete(:instrumenter) @retry_strategy = @options.delete(:retry_strategy) @driver = Cassanity::Cql::ReconnectableDriver.connect(@options) @executor = Cassanity::Executors::CqlRb.new({ driver: @driver, instrumenter: @instrumenter, retry_strategy: @retry_strategy, }) @connection = Cassanity::Connection.new({ executor: @executor, }) end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Public: The instance of the Cassanity::Connection that is the entry point for all operations.
20 21 22 |
# File 'lib/cassanity/client.rb', line 20 def connection @connection end |
#driver ⇒ Object (readonly)
Public: The instance of the Cql::Client being used.
12 13 14 |
# File 'lib/cassanity/client.rb', line 12 def driver @driver end |
#executor ⇒ Object (readonly)
Public: The instance of the Cassanity::Executors::CqlRb that will execute all queries.
16 17 18 |
# File 'lib/cassanity/client.rb', line 16 def executor @executor end |
Instance Method Details
#connect ⇒ Object
Reconnect to cassandra.
51 52 53 |
# File 'lib/cassanity/client.rb', line 51 def connect @driver.connect end |
#connected? ⇒ Boolean
60 61 62 |
# File 'lib/cassanity/client.rb', line 60 def connected? @driver.connected? end |
#disconnect ⇒ Object
Disconnect from cassandra.
56 57 58 |
# File 'lib/cassanity/client.rb', line 56 def disconnect @driver.disconnect end |
#inspect ⇒ Object
Public
75 76 77 78 79 80 81 82 |
# File 'lib/cassanity/client.rb', line 75 def inspect attributes = [ "driver=#{driver.inspect}", "executor=#{executor.inspect}", "connection=#{connection.inspect}", ] "#<#{self.class.name}:#{object_id} #{attributes.join(', ')}>" end |