Module: Cassie::ConnectionHandler

Includes:
Cluster, Sessions
Included in:
Cassie
Defined in:
lib/cassie/connection_handler.rb,
lib/cassie/connection_handler/cluster.rb,
lib/cassie/connection_handler/logging.rb,
lib/cassie/connection_handler/sessions.rb

Overview

Extend Cassie::ConnectionHandler to provide cluster and session cacheing in line with Cassandra best practices.

The extending class must provide two methods that will be used by the connection handler for connections:

  • self.configuration

    • A configuration hash defining cluster options per environment

    • Used when connecting through cassandra_driver

    • See [Configuration::Core] for a sample implementation with a .yml back-end

  • self.keyspace

    • The default keyspace to connect to when none is specified for a session.

Defined Under Namespace

Modules: Cluster, Logging, Sessions

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#clusterCassandra::Cluster (readonly) Originally defined in module Cluster

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

#sessionsHash{String => Cassandra::Session} (readonly) Originally defined in module Sessions

Sessions cache containint sessions that have been opened to the Cluster#cluster

Returns:

  • (Hash{String => Cassandra::Session})

    The underlying driver sessions, keyed by keyspaced name

Instance Method Details

#keyspace_exists?(name) ⇒ Boolean Originally defined in module Cluster

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

#session(keyspace = self.keyspace) ⇒ Cassandra::Session Originally defined in module Sessions

Fetches a session from the sessions cache. If no session has been opened to the requested keyspace a new session is created to the Cluster#cluster and cached.

Parameters:

  • keyspace (String) (defaults to: self.keyspace)

    The keyspace used for session scope. If nil, session will not be scoped (scoped to global space).

Returns:

  • (Cassandra::Session)