Class: OnStomp::Failover::Pools::RoundRobin
- Defined in:
- lib/onstomp/failover/pools/round_robin.rb
Overview
A round-robin client pool. Clients are processed sequentially, and once all clients have been processed, the pool cycles back to the beginning.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(uris, options = {}) ⇒ RoundRobin
constructor
A new instance of RoundRobin.
-
#next_client ⇒ OnStomp::Client
Returns the next sequential client in the pool.
Methods inherited from Base
Constructor Details
#initialize(uris, options = {}) ⇒ RoundRobin
Returns a new instance of RoundRobin.
6 7 8 9 |
# File 'lib/onstomp/failover/pools/round_robin.rb', line 6 def initialize uris, = {} super @index = -1 end |
Instance Method Details
#next_client ⇒ OnStomp::Client
Returns the next sequential client in the pool
13 14 15 16 |
# File 'lib/onstomp/failover/pools/round_robin.rb', line 13 def next_client @index = (@index + 1) % clients.size clients[@index] end |