Class: Octopus::LoadBalancing::RoundRobin
- Inherits:
-
Object
- Object
- Octopus::LoadBalancing::RoundRobin
- Defined in:
- lib/octopus/load_balancing/round_robin.rb
Instance Method Summary collapse
-
#initialize(slaves_list) ⇒ RoundRobin
constructor
A new instance of RoundRobin.
-
#next(options) ⇒ Object
Returns the next available slave in the pool.
Constructor Details
#initialize(slaves_list) ⇒ RoundRobin
Returns a new instance of RoundRobin.
8 9 10 11 12 |
# File 'lib/octopus/load_balancing/round_robin.rb', line 8 def initialize(slaves_list) raise Octopus::Exception.new("No slaves available") if slaves_list.empty? @slaves_list = slaves_list @slave_index = 0 end |
Instance Method Details
#next(options) ⇒ Object
Returns the next available slave in the pool
15 16 17 |
# File 'lib/octopus/load_balancing/round_robin.rb', line 15 def next() @slaves_list[@slave_index = (@slave_index + 1) % @slaves_list.length] end |