Class: FreshConnection::ReplicaConnectionHandler
- Inherits:
-
Object
- Object
- FreshConnection::ReplicaConnectionHandler
- Defined in:
- lib/fresh_connection/replica_connection_handler.rb
Instance Method Summary collapse
- #clear_all_connections! ⇒ Object
- #connection(klass) ⇒ Object
- #establish_connection(name, replica_group) ⇒ Object
-
#initialize ⇒ ReplicaConnectionHandler
constructor
A new instance of ReplicaConnectionHandler.
- #put_aside! ⇒ Object
- #recovery?(klass) ⇒ Boolean
- #replica_group(klass) ⇒ Object
Constructor Details
#initialize ⇒ ReplicaConnectionHandler
Returns a new instance of ReplicaConnectionHandler.
5 6 7 |
# File 'lib/fresh_connection/replica_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/replica_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/replica_connection_handler.rb', line 17 def connection(klass) detect_connection_manager(klass).replica_connection end |
#establish_connection(name, replica_group) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/fresh_connection/replica_connection_handler.rb', line 9 def establish_connection(name, replica_group) if cm = class_to_pool[name] cm.put_aside! end class_to_pool[name] = FreshConnection.connection_manager.new(replica_group) end |
#put_aside! ⇒ Object
31 32 33 34 35 |
# File 'lib/fresh_connection/replica_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/replica_connection_handler.rb', line 27 def recovery?(klass) detect_connection_manager(klass).recovery? end |
#replica_group(klass) ⇒ Object
37 38 39 |
# File 'lib/fresh_connection/replica_connection_handler.rb', line 37 def replica_group(klass) detect_connection_manager(klass).replica_group end |