Sha256: 139a783129e8555908d927b38bf783fce46a206d0457cc89c5a2face2a104935
Contents?: true
Size: 726 Bytes
Versions: 13
Compression:
Stored size: 726 Bytes
Contents
module ProconBypassMan class ServerPool def initialize(servers: ) if servers.nil? || servers.empty? return end @servers = servers if @servers.size >= 1 @index = 0 else @index = nil end end def pick if @index.nil? return @servers&.first end @servers[@index] or raise "bug!!!" end def server; pick; end def next! inc_index if @servers[@index].nil? reset return end end private def reset @index = 0 end def inc_index @index = @index + 1 end end end if $0 == __FILE__ ProconBypassMan::ServerPool.new(servers: ['http://example.com']) end
Version data entries
13 entries across 13 versions & 1 rubygems