Class: Cassanity::Cql::ReconnectableDriver
- Inherits:
-
Object
- Object
- Cassanity::Cql::ReconnectableDriver
- Extended by:
- Forwardable
- Defined in:
- lib/cassanity/cql/reconnectable_driver.rb
Overview
Internal: An intermediate driver for cql-rb that supports reconnecting by recycling the underlying Cql::Client instance.
Reconnecting is important when using a forking web server like unicorn, but cql-rb does not allow a Cql::Client instances that has been disconnected to be reconnected.
Class Method Summary collapse
Instance Method Summary collapse
- #connect ⇒ Object
- #disconnect ⇒ Object
-
#initialize(cql_options = {}) ⇒ ReconnectableDriver
constructor
cql_options: Options for constructing a Cql::Client.
Constructor Details
#initialize(cql_options = {}) ⇒ ReconnectableDriver
cql_options: Options for constructing a Cql::Client
20 21 22 |
# File 'lib/cassanity/cql/reconnectable_driver.rb', line 20 def initialize( = {}) @cql_options = end |
Class Method Details
.connect(cql_options = {}) ⇒ Object
15 16 17 |
# File 'lib/cassanity/cql/reconnectable_driver.rb', line 15 def self.connect( = {}) new().tap(&:connect) end |
Instance Method Details
#connect ⇒ Object
24 25 26 27 |
# File 'lib/cassanity/cql/reconnectable_driver.rb', line 24 def connect disconnect @driver = ::Cql::Client.connect(@cql_options) end |
#disconnect ⇒ Object
29 30 31 |
# File 'lib/cassanity/cql/reconnectable_driver.rb', line 29 def disconnect @driver.close if @driver end |