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.
269 270 271 272 273 |
# File 'lib/active_record/connection_adapters/seamless_database_pool_adapter.rb', line 269 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.
266 267 268 |
# File 'lib/active_record/connection_adapters/seamless_database_pool_adapter.rb', line 266 def connections @connections end |
#expires=(value) ⇒ Object (writeonly)
Sets the attribute expires
267 268 269 |
# File 'lib/active_record/connection_adapters/seamless_database_pool_adapter.rb', line 267 def expires=(value) @expires = value end |
#failed_connection ⇒ Object (readonly)
Returns the value of attribute failed_connection.
266 267 268 |
# File 'lib/active_record/connection_adapters/seamless_database_pool_adapter.rb', line 266 def failed_connection @failed_connection end |
Instance Method Details
#expired? ⇒ Boolean
275 276 277 |
# File 'lib/active_record/connection_adapters/seamless_database_pool_adapter.rb', line 275 def expired? @expires ? @expires <= Time.now : false end |
#reconnect! ⇒ Object
279 280 281 282 |
# File 'lib/active_record/connection_adapters/seamless_database_pool_adapter.rb', line 279 def reconnect! failed_connection.reconnect! raise DatabaseConnectionError.new unless failed_connection.active? end |