Class: FreshConnection::SlaveConnectionHandler
- Inherits:
-
Object
- Object
- FreshConnection::SlaveConnectionHandler
- Defined in:
- lib/fresh_connection/slave_connection_handler.rb
Instance Method Summary collapse
- #connection(klass) ⇒ Object
- #establish_connection(name, slave_group) ⇒ Object
-
#initialize ⇒ SlaveConnectionHandler
constructor
A new instance of SlaveConnectionHandler.
- #put_aside! ⇒ Object
- #recovery(klass, failure_connection, exception) ⇒ Object
- #slave_group(klass) ⇒ Object
Constructor Details
#initialize ⇒ SlaveConnectionHandler
Returns a new instance of SlaveConnectionHandler.
3 4 5 |
# File 'lib/fresh_connection/slave_connection_handler.rb', line 3 def initialize @class_to_pool = {} end |
Instance Method Details
#connection(klass) ⇒ Object
15 16 17 |
# File 'lib/fresh_connection/slave_connection_handler.rb', line 15 def connection(klass) detect_connection_manager(klass).slave_connection end |
#establish_connection(name, slave_group) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/fresh_connection/slave_connection_handler.rb', line 7 def establish_connection(name, slave_group) if cm = @class_to_pool[name] cm.put_aside! end @class_to_pool[name] = FreshConnection.connection_manager.new(slave_group) end |
#put_aside! ⇒ Object
19 20 21 22 23 |
# File 'lib/fresh_connection/slave_connection_handler.rb', line 19 def put_aside! @class_to_pool.values.each do |connection_manager| connection_manager.put_aside! end end |
#recovery(klass, failure_connection, exception) ⇒ Object
25 26 27 |
# File 'lib/fresh_connection/slave_connection_handler.rb', line 25 def recovery(klass, failure_connection, exception) detect_connection_manager(klass).recovery(failure_connection, exception) end |
#slave_group(klass) ⇒ Object
29 30 31 |
# File 'lib/fresh_connection/slave_connection_handler.rb', line 29 def slave_group(klass) detect_connection_manager(klass).slave_group end |