Class: ActiveRecord::ConnectionAdapters::SeamlessDatabasePoolAdapter::AvailableConnections
- Inherits:
-
Object
- Object
- ActiveRecord::ConnectionAdapters::SeamlessDatabasePoolAdapter::AvailableConnections
- Defined in:
- lib/active_record/connection_adapters/seamless_database_pool_adapter.rb
Overview
This simple class puts an expire time on an array of connections. It is used so the a connection to a down database won’t try to reconnect over and over.
Instance Attribute Summary collapse
-
#connections ⇒ Object
readonly
Returns the value of attribute connections.
-
#expires ⇒ Object
writeonly
Sets the attribute expires.
-
#failed_connection ⇒ Object
readonly
Returns the value of attribute failed_connection.
Instance Method Summary collapse
- #expired? ⇒ Boolean
-
#initialize(connections, failed_connection = nil, expires = nil) ⇒ AvailableConnections
constructor
A new instance of AvailableConnections.
- #reconnect! ⇒ Object
Constructor Details
#initialize(connections, failed_connection = nil, expires = nil) ⇒ AvailableConnections
Returns a new instance of AvailableConnections.
277 278 279 280 281 |
# File 'lib/active_record/connection_adapters/seamless_database_pool_adapter.rb', line 277 def initialize(connections, failed_connection = nil, expires = nil) @connections = connections @failed_connection = failed_connection @expires = expires end |
Instance Attribute Details
#connections ⇒ Object (readonly)
Returns the value of attribute connections.
274 275 276 |
# File 'lib/active_record/connection_adapters/seamless_database_pool_adapter.rb', line 274 def connections @connections end |
#expires=(value) ⇒ Object (writeonly)
Sets the attribute expires
275 276 277 |
# File 'lib/active_record/connection_adapters/seamless_database_pool_adapter.rb', line 275 def expires=(value) @expires = value end |
#failed_connection ⇒ Object (readonly)
Returns the value of attribute failed_connection.
274 275 276 |
# File 'lib/active_record/connection_adapters/seamless_database_pool_adapter.rb', line 274 def failed_connection @failed_connection end |
Instance Method Details
#expired? ⇒ Boolean
283 284 285 |
# File 'lib/active_record/connection_adapters/seamless_database_pool_adapter.rb', line 283 def expired? @expires ? @expires <= Time.now : false end |
#reconnect! ⇒ Object
287 288 289 290 |
# File 'lib/active_record/connection_adapters/seamless_database_pool_adapter.rb', line 287 def reconnect! failed_connection.reconnect! raise DatabaseConnectionError.new unless failed_connection.active? end |