Class: Servicy::RandomLoadBalancer
- Inherits:
-
LoadBalancer
- Object
- LoadBalancer
- Servicy::RandomLoadBalancer
- Defined in:
- lib/load_balancer/random.rb
Instance Attribute Summary
Attributes inherited from LoadBalancer
Instance Method Summary collapse
-
#initialize ⇒ RandomLoadBalancer
constructor
A new instance of RandomLoadBalancer.
- #next_for_service(service_name) ⇒ Object
Methods inherited from LoadBalancer
Constructor Details
#initialize ⇒ RandomLoadBalancer
Returns a new instance of RandomLoadBalancer.
3 4 5 6 |
# File 'lib/load_balancer/random.rb', line 3 def initialize super @last_host_index = {} end |
Instance Method Details
#next_for_service(service_name) ⇒ Object
8 9 10 |
# File 'lib/load_balancer/random.rb', line 8 def next_for_service(service_name) hosts[service_name][rand(hosts[service_name].length)] end |