class MaZMQ::Proxy::Balancer
Public Class Methods
new()
click to toggle source
# File lib/ma-zmq/proxy/balancer.rb, line 12 def initialize self.strategy = :round_robin # default strategy is round_robin @index = [] # @data = [] # connections, load end
Public Instance Methods
add(index)
click to toggle source
# File lib/ma-zmq/proxy/balancer.rb, line 23 def add(index) @index << index end
current()
click to toggle source
# File lib/ma-zmq/proxy/balancer.rb, line 31 def current @index[0] end
next()
click to toggle source
# File lib/ma-zmq/proxy/balancer.rb, line 35 def next case @strategy when :round_robin @index.push(@index.shift) end end
remove(index)
click to toggle source
# File lib/ma-zmq/proxy/balancer.rb, line 27 def remove(index) @index.delete(index) end
strategy=(strategy)
click to toggle source
# File lib/ma-zmq/proxy/balancer.rb, line 18 def strategy=(strategy) return false if not @@strategies.include? strategy @strategy = strategy end