Class: Servicy::LoadBalancer
- Inherits:
-
Object
- Object
- Servicy::LoadBalancer
- Defined in:
- lib/load_balancer.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#hosts ⇒ Object
Returns the value of attribute hosts.
Instance Method Summary collapse
-
#initialize ⇒ LoadBalancer
constructor
A new instance of LoadBalancer.
- #next(set) ⇒ Object
- #next_for_service(service_name) ⇒ Object
Constructor Details
#initialize ⇒ LoadBalancer
Returns a new instance of LoadBalancer.
5 6 7 |
# File 'lib/load_balancer.rb', line 5 def initialize @hosts = {} end |
Instance Attribute Details
#hosts ⇒ Object
Returns the value of attribute hosts.
3 4 5 |
# File 'lib/load_balancer.rb', line 3 def hosts @hosts end |
Instance Method Details
#next(set) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/load_balancer.rb', line 9 def next(set) return nil if set.empty? hosts[set.first.name] ||= [] hosts[set.first.name] += set hosts[set.first.name].uniq! next_for_service(set.first.name) end |
#next_for_service(service_name) ⇒ Object
17 18 19 |
# File 'lib/load_balancer.rb', line 17 def next_for_service(service_name) raise 'Not implemented' end |