class Cassandra::LoadBalancing::Policies::RoundRobin::Plan
@private
Public Class Methods
new(hosts, index)
click to toggle source
# File lib/cassandra/load_balancing/policies/round_robin.rb 25 def initialize(hosts, index) 26 @hosts = hosts 27 @index = index 28 29 @total = @remaining = hosts.size 30 end
Public Instance Methods
has_next?()
click to toggle source
# File lib/cassandra/load_balancing/policies/round_robin.rb 32 def has_next? 33 @remaining > 0 34 end
next()
click to toggle source
# File lib/cassandra/load_balancing/policies/round_robin.rb 36 def next 37 return if @remaining == 0 38 39 @remaining -= 1 40 index = @index 41 @index = (index + 1) % @total 42 43 @hosts[index] 44 end