class Octopus::LoadBalancing::RoundRobin

Public Class Methods

new(slaves_list) click to toggle source
# 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

Public Instance Methods

next(options) click to toggle source

Returns the next available slave in the pool

# File lib/octopus/load_balancing/round_robin.rb, line 15
def next(options)
  @slaves_list[@slave_index = (@slave_index + 1) % @slaves_list.length]
end