Sha256: 7ef4e90e4bb58303bdad76c33e76b581aed3142e96fa3f547d890a05d41d3ef3
Contents?: true
Size: 605 Bytes
Versions: 8
Compression:
Stored size: 605 Bytes
Contents
require 'octopus/load_balancing' # The round-robin load balancing of slaves belonging to the same shard. # It is a pool that contains slaves which queries are distributed to. module Octopus module LoadBalancing class RoundRobin def initialize(slaves_list) raise Octopus::Exception.new("No slaves available") if slaves_list.empty? @slaves_list = slaves_list @slave_index = 0 end # Returns the next available slave in the pool def next(options) @slaves_list[@slave_index = (@slave_index + 1) % @slaves_list.length] end end end end
Version data entries
8 entries across 8 versions & 3 rubygems