Class: XRBP::WebSocket::RoundRobin
- Inherits:
-
MultiConnection
- Object
- MultiConnection
- XRBP::WebSocket::RoundRobin
- Defined in:
- lib/xrbp/websocket/multi/round_robin.rb
Overview
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.
Instance Attribute Summary
Attributes inherited from MultiConnection
Instance Method Summary collapse
-
#initialize(*urls) ⇒ RoundRobin
constructor
A new instance of RoundRobin.
- #next_connection(prev = nil) ⇒ Object
Methods inherited from MultiConnection
#_add_plugin, #add_plugin, #close!, #connect, #force_quit!, #plugin_namespace, #wait_for_close, #wait_for_completed, #wait_for_open
Constructor Details
#initialize(*urls) ⇒ RoundRobin
Returns a new instance of RoundRobin.
8 9 10 11 |
# File 'lib/xrbp/websocket/multi/round_robin.rb', line 8 def initialize(*urls) super(*urls) @current = 0 end |
Instance Method Details
#next_connection(prev = nil) ⇒ Object
13 14 15 16 17 18 19 20 |
# 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 |