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.
283 284 285 286 287 |
# File 'lib/active_record/connection_adapters/seamless_database_pool_adapter.rb', line 283 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.
280 281 282 |
# File 'lib/active_record/connection_adapters/seamless_database_pool_adapter.rb', line 280 def connections @connections end |
#expires=(value) ⇒ Object (writeonly)
Sets the attribute expires
281 282 283 |
# File 'lib/active_record/connection_adapters/seamless_database_pool_adapter.rb', line 281 def expires=(value) @expires = value end |
#failed_connection ⇒ Object (readonly)
Returns the value of attribute failed_connection.
280 281 282 |
# File 'lib/active_record/connection_adapters/seamless_database_pool_adapter.rb', line 280 def failed_connection @failed_connection end |
Instance Method Details
#expired? ⇒ Boolean
289 290 291 |
# File 'lib/active_record/connection_adapters/seamless_database_pool_adapter.rb', line 289 def expired? @expires ? @expires <= Time.now : false end |
#reconnect! ⇒ Object
293 294 295 296 |
# File 'lib/active_record/connection_adapters/seamless_database_pool_adapter.rb', line 293 def reconnect! failed_connection.reconnect! raise DatabaseConnectionError.new unless failed_connection.active? end |