Class: FreshConnection::ReplicaConnectionHandler
- Inherits:
-
Object
- Object
- FreshConnection::ReplicaConnectionHandler
- Includes:
- Singleton
- Defined in:
- lib/fresh_connection/replica_connection_handler.rb
Instance Method Summary collapse
- #clear_all_connections! ⇒ Object
- #connection(spec_name) ⇒ Object
-
#initialize ⇒ ReplicaConnectionHandler
constructor
A new instance of ReplicaConnectionHandler.
- #put_aside! ⇒ Object
- #recovery?(spec_name) ⇒ Boolean
- #refresh_all ⇒ Object
- #refresh_connection(spec_name) ⇒ Object
Constructor Details
#initialize ⇒ ReplicaConnectionHandler
Returns a new instance of ReplicaConnectionHandler.
9 10 11 12 13 |
# File 'lib/fresh_connection/replica_connection_handler.rb', line 9 def initialize @owner_to_pool = Concurrent::Map.new(initial_capacity: 2) do |h, k| h[k] = Concurrent::Map.new(initial_capacity: 2) end end |
Instance Method Details
#clear_all_connections! ⇒ Object
27 28 29 30 31 |
# File 'lib/fresh_connection/replica_connection_handler.rb', line 27 def clear_all_connections! all_connection_managers do |connection_manager| connection_manager.clear_all_connections! end end |
#connection(spec_name) ⇒ Object
23 24 25 |
# File 'lib/fresh_connection/replica_connection_handler.rb', line 23 def connection(spec_name) detect_connection_manager(spec_name).replica_connection end |
#put_aside! ⇒ Object
37 38 39 40 41 |
# File 'lib/fresh_connection/replica_connection_handler.rb', line 37 def put_aside! all_connection_managers do |connection_manager| connection_manager.put_aside! end end |
#recovery?(spec_name) ⇒ Boolean
33 34 35 |
# File 'lib/fresh_connection/replica_connection_handler.rb', line 33 def recovery?(spec_name) detect_connection_manager(spec_name).recovery? end |
#refresh_all ⇒ Object
15 16 17 |
# File 'lib/fresh_connection/replica_connection_handler.rb', line 15 def refresh_all owner_to_pool.clear end |
#refresh_connection(spec_name) ⇒ Object
19 20 21 |
# File 'lib/fresh_connection/replica_connection_handler.rb', line 19 def refresh_connection(spec_name) remove_connection(spec_name.to_s) end |