Module: Cql::Client
- Defined in:
- lib/cql/client.rb,
lib/cql/client/null_logger.rb,
lib/cql/client/query_result.rb,
lib/cql/client/request_runner.rb,
lib/cql/client/column_metadata.rb,
lib/cql/client/result_metadata.rb,
lib/cql/client/keyspace_changer.rb,
lib/cql/client/connection_helper.rb,
lib/cql/client/connection_manager.rb,
lib/cql/client/synchronous_client.rb,
lib/cql/client/asynchronous_client.rb,
lib/cql/client/execute_options_decoder.rb,
lib/cql/client/synchronous_prepared_statement.rb,
lib/cql/client/asynchronous_prepared_statement.rb
Overview
A CQL client manages connections to one or more Cassandra nodes and you use it run queries, insert and update data.
Client instances are threadsafe.
See Client for the full client API, or Client.connect for the options available when connecting.
Defined Under Namespace
Modules: SynchronousBacktrace Classes: AsynchronousClient, AsynchronousPreparedStatement, AuthenticationRequired, Client, ColumnMetadata, ConnectionHelper, ConnectionManager, ExecuteOptionsDecoder, KeyspaceChanged, KeyspaceChanger, NullLogger, Pipeline, PreparedStatement, QueryResult, RequestRunner, ResultMetadata, SynchronousClient, SynchronousPreparedStatement
Constant Summary collapse
- InvalidKeyspaceNameError =
Class.new(ClientError)
Class Method Summary collapse
-
.connect(options = {}) ⇒ Cql::Client::Client
Create a new client and connect to Cassandra.
Instance Method Summary collapse
-
#close ⇒ Cql::Client
Disconnect from all nodes.
-
#connect ⇒ Cql::Client
Connect to all nodes.
-
#connected? ⇒ true, false
Returns whether or not the client is connected.
-
#execute(cql, options_or_consistency = nil) ⇒ nil, Cql::Client::QueryResult
Execute a CQL statement.
-
#keyspace ⇒ String
Returns the name of the current keyspace, or ‘nil` if no keyspace has been set yet.
-
#prepare(cql) ⇒ Cql::Client::PreparedStatement
Returns a prepared statement that can be run over and over again with different values.
-
#use(keyspace) ⇒ nil
Changes keyspace by sending a ‘USE` statement to all connections.
Class Method Details
.connect(options = {}) ⇒ Cql::Client::Client
Create a new client and connect to Cassandra.
By default the client will connect to localhost port 9042, which can be overridden with the ‘:hosts` and `:port` options, respectively. Once connected to the hosts given in `:hosts` the rest of the nodes in the cluster will automatically be discovered and connected to.
If you have a multi data center setup the client will connect to all nodes in the data centers where the nodes you pass to ‘:hosts` are located. So if you only want to connect to nodes in one data center, make sure that you only specify nodes in that data center in `:hosts`.
The connection will succeed if at least one node is up and accepts the connection. Nodes that don’t respond within the specified timeout, or where the connection initialization fails for some reason, are ignored.
98 99 100 |
# File 'lib/cql/client.rb', line 98 def self.connect(={}) SynchronousClient.new(AsynchronousClient.new()).connect end |
Instance Method Details
#connect ⇒ Cql::Client
Connect to all nodes. See connect for the full documentation.
This method needs to be called before any other. Calling it again will have no effect.
|
# File 'lib/cql/client.rb', line 103
|
#connected? ⇒ true, false
Returns whether or not the client is connected.
|
# File 'lib/cql/client.rb', line 120
|
#execute(cql, options_or_consistency = nil) ⇒ nil, Cql::Client::QueryResult
Execute a CQL statement
|
# File 'lib/cql/client.rb', line 143
|
#keyspace ⇒ String
Returns the name of the current keyspace, or ‘nil` if no keyspace has been set yet.
|
# File 'lib/cql/client.rb', line 126
|
#prepare(cql) ⇒ Cql::Client::PreparedStatement
Returns a prepared statement that can be run over and over again with different values.
|
# File 'lib/cql/client.rb', line 165
|
#use(keyspace) ⇒ nil
Changes keyspace by sending a ‘USE` statement to all connections.
The the second parameter is meant for internal use only.
|
# File 'lib/cql/client.rb', line 133
|