Class: OnStomp::Failover::Pools::RoundRobin

Inherits:
Base
  • Object
show all
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

clients

Instance Method Summary (collapse)

Methods inherited from Base

#each, #shuffle!

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

Returns:



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