class Backend
Attributes
conf[RW]
not_ready[RW]
Public Class Methods
new(conf)
click to toggle source
# File lib/galerab/backend.rb, line 4 def initialize(conf) @next_host = 0 @list = conf['backends'] @conf = conf @not_ready = Array.new end
Public Instance Methods
get_next()
click to toggle source
round robin load-balancing
# File lib/galerab/backend.rb, line 12 def get_next @next_host = @next_host + 1 @next_host = 0 if @next_host >= @list.size unless @not_ready.include?(@list[@next_host]) @list[@next_host] else begin get_next rescue SystemStackError nil end end end