class XRBP::WebSocket::RoundRobin

MultiConnection strategy where connections selected in a circular-round robin manner, where the next connection is always used for the next request even if the current one succeeds.

Public Class Methods

new(*urls) click to toggle source
Calls superclass method XRBP::WebSocket::MultiConnection::new
# File lib/xrbp/websocket/multi/round_robin.rb, line 8
def initialize(*urls)
  super(*urls)
  @current = 0
end

Public Instance Methods

next_connection(prev=nil) click to toggle source
# File lib/xrbp/websocket/multi/round_robin.rb, line 13
def next_connection(prev=nil)
  return nil unless prev.nil?

  c = connections[@current]
  @current += 1
  @current  = 0 if @current >= connections.size
  c
end