Class: Servicy::RandomLoadBalancer

Inherits:
LoadBalancer show all
Defined in:
lib/load_balancer/random.rb

Instance Attribute Summary

Attributes inherited from LoadBalancer

#hosts

Instance Method Summary collapse

Methods inherited from LoadBalancer

#next

Constructor Details

#initializeRandomLoadBalancer

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