Class: FreshConnection::SlaveConnectionHandler
- Inherits:
-
Object
- Object
- FreshConnection::SlaveConnectionHandler
- Defined in:
- lib/fresh_connection/slave_connection_handler.rb
Instance Method Summary collapse
- #clear_all_connections! ⇒ Object
- #connection(klass) ⇒ Object
- #establish_connection(name, slave_group) ⇒ Object
-
#initialize ⇒ SlaveConnectionHandler
constructor
A new instance of SlaveConnectionHandler.
- #put_aside! ⇒ Object
- #recovery?(klass) ⇒ Boolean
- #slave_group(klass) ⇒ Object
Constructor Details
#initialize ⇒ SlaveConnectionHandler
Returns a new instance of SlaveConnectionHandler.
5 6 7 |
# File 'lib/fresh_connection/slave_connection_handler.rb', line 5 def initialize @class_to_pool = Concurrent::Map.new end |
Instance Method Details
#clear_all_connections! ⇒ Object
21 22 23 24 25 |
# File 'lib/fresh_connection/slave_connection_handler.rb', line 21 def clear_all_connections! all_connection_managers do |connection_manager| connection_manager.clear_all_connections! end end |
#connection(klass) ⇒ Object
17 18 19 |
# File 'lib/fresh_connection/slave_connection_handler.rb', line 17 def connection(klass) detect_connection_manager(klass).slave_connection end |
#establish_connection(name, slave_group) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/fresh_connection/slave_connection_handler.rb', line 9 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
31 32 33 34 35 |
# File 'lib/fresh_connection/slave_connection_handler.rb', line 31 def put_aside! all_connection_managers do |connection_manager| connection_manager.put_aside! end end |
#recovery?(klass) ⇒ Boolean
27 28 29 |
# File 'lib/fresh_connection/slave_connection_handler.rb', line 27 def recovery?(klass) detect_connection_manager(klass).recovery? end |
#slave_group(klass) ⇒ Object
37 38 39 |
# File 'lib/fresh_connection/slave_connection_handler.rb', line 37 def slave_group(klass) detect_connection_manager(klass).slave_group end |