Module: Cassie::ConnectionHandler::Cluster

Extended by:
ActiveSupport::Concern
Included in:
Cassie::ConnectionHandler
Defined in:
lib/cassie/connection_handler/cluster.rb,
lib/cassie/connection_handler/cluster/instrumentation.rb

Overview

## Cassie::ConnectionHandler::Cluster

Adds cluster instance configuration and memoization.

Include in any class or module that responds to `configuration` with a cassandra cluster options hash.

Defined Under Namespace

Modules: Instrumentation

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#clusterCassandra::Cluster (readonly)

The cluster connection and metadata. This cluster connection is lazy-loaded, not calling out to Cassandra until it is first accessed. The single cluster object is cached for the entire process.

Returns:

  • (Cassandra::Cluster)

    The underlying driver cluster object


21
22
23
24
25
26
# File 'lib/cassie/connection_handler/cluster.rb', line 21

def cluster  # Cassandra::cluster parses suppored
  # options from the passed hash, no need
  # to validate/transform ourselves yet

  @cluster ||= initialize_cluster
end

Instance Method Details

#keyspace_exists?(name) ⇒ Boolean

Returns indicating if the cluster has the keyspace defined.

Parameters:

  • name (String, Symbol)

    The keyspace name to search for

Returns:

  • (Boolean)

    indicating if the cluster has the keyspace defined


30
31
32
# File 'lib/cassie/connection_handler/cluster.rb', line 30

def keyspace_exists?(name)
  Cassie.cluster.keyspaces.map(&:name).any?{|k| k.to_s == name.to_s}
end