Class: EbisuConnection::ConnectionManager
- Inherits:
-
FreshConnection::AbstractConnectionManager
- Object
- FreshConnection::AbstractConnectionManager
- EbisuConnection::ConnectionManager
show all
- Defined in:
- lib/ebisu_connection/connection_manager.rb
Defined Under Namespace
Classes: AllReplicaHasGoneError
Instance Method Summary
collapse
Constructor Details
Returns a new instance of ConnectionManager.
8
9
10
11
12
13
14
|
# File 'lib/ebisu_connection/connection_manager.rb', line 8
def initialize(spec_name = nil)
super
@replicas = replica_conf.map do |conf|
Replica.new(conf, spec_name)
end
end
|
Instance Method Details
#clear_all_connections! ⇒ Object
25
26
27
|
# File 'lib/ebisu_connection/connection_manager.rb', line 25
def clear_all_connections!
@replicas.each(&:disconnect!)
end
|
#put_aside! ⇒ Object
21
22
23
|
# File 'lib/ebisu_connection/connection_manager.rb', line 21
def put_aside!
@replicas.each(&:put_aside!)
end
|
#recovery? ⇒ Boolean
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/ebisu_connection/connection_manager.rb', line 29
def recovery?
dead_replicas = @replicas.select do |replica|
c = replica.connection rescue nil
!c || !c.active?
end
return false if dead_replicas.empty?
dead_replicas.each do |replica|
replica.disconnect!
@replicas.delete(replica)
end
raise AllReplicaHasGoneError if @replicas.empty?
@load_balancer = nil
true
end
|
#replica_connection ⇒ Object
16
17
18
19
|
# File 'lib/ebisu_connection/connection_manager.rb', line 16
def replica_connection
raise AllReplicaHasGoneError if @replicas.empty?
load_balancer.replica.connection
end
|