Class: HAProxyCluster::Backend
- Inherits:
-
StatsContainer
- Object
- StatsContainer
- HAProxyCluster::Backend
- Defined in:
- lib/haproxy_cluster/backend.rb
Constant Summary collapse
- TYPE_ID =
1
Instance Attribute Summary collapse
-
#member ⇒ Object
readonly
Returns the value of attribute member.
-
#servers ⇒ Object
Returns the value of attribute servers.
Attributes inherited from StatsContainer
Instance Method Summary collapse
-
#initialize(stats, member = nil) ⇒ Backend
constructor
A new instance of Backend.
- #name ⇒ Object
- #rolling_restartable?(enough = 80) ⇒ Boolean
Methods inherited from StatsContainer
Constructor Details
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class HAProxyCluster::StatsContainer
Instance Attribute Details
#member ⇒ Object (readonly)
Returns the value of attribute member.
15 16 17 |
# File 'lib/haproxy_cluster/backend.rb', line 15 def member @member end |
#servers ⇒ Object
Returns the value of attribute servers.
14 15 16 |
# File 'lib/haproxy_cluster/backend.rb', line 14 def servers @servers end |
Instance Method Details
#name ⇒ Object
17 18 19 |
# File 'lib/haproxy_cluster/backend.rb', line 17 def name self.pxname end |
#rolling_restartable?(enough = 80) ⇒ Boolean
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/haproxy_cluster/backend.rb', line 21 def rolling_restartable? (enough = 80) up_servers = @servers.select{ |name,server| server.ok? } if up_servers.count == 0 @member.log.warn { "All servers are down; can't hurt!" } return true elsif Rational(up_servers.count,@servers.count) >= Rational(enough,100) @member.log.info { "#{up_servers.count}/#{@servers.count} is at least #{enough}%, so #{name} is rolling restartable." } return true else @member.log.warn { "Insufficient capacity to handle a rolling restart at this time. (#{up_servers.count}/#{@servers.count})" } return false end end |