Class: OnStomp::Failover::Pools::RoundRobin
- Inherits:
-
Base
- Object
- Base
- 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)
-
- (RoundRobin) initialize(uris)
constructor
A new instance of RoundRobin.
-
- (OnStomp::Client) next_client
Returns the next sequential client in the pool.
Methods inherited from Base
Constructor Details
- (RoundRobin) initialize(uris)
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
- (OnStomp::Client) next_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 |