Class: OnStomp::Failover::Pools::Base
- Inherits:
-
Object
- Object
- OnStomp::Failover::Pools::Base
- Defined in:
- lib/onstomp/failover/pools/base.rb
Overview
An abstract pool of clients. This class manages the shared behaviors
of client pools, but has no means of picking successive clients.
Subclasses must define next_client
or pool will not function.
Direct Known Subclasses
Instance Attribute Summary (collapse)
-
- (Object) clients
readonly
Returns the value of attribute clients.
Instance Method Summary (collapse)
-
- (self) each {|client| ... }
Yields each client in the pool to the supplied block.
-
- (Base) initialize(hosts)
constructor
Creates a new client pool by mapping an array of URIs into an array of clients.
-
- (Object) next_client
Raises an error, because it is up to subclasses to define this behavior.
-
- (Object) shuffle!
Shuffles the client pool.
Constructor Details
Instance Attribute Details
- (Object) clients (readonly)
Returns the value of attribute clients
7 8 9 |
# File 'lib/onstomp/failover/pools/base.rb', line 7 def clients @clients end |
Instance Method Details
- (self) each {|client| ... }
Yields each client in the pool to the supplied block. Raises an error if no block is provided.
34 35 36 37 38 |
# File 'lib/onstomp/failover/pools/base.rb', line 34 def each &block raise ArgumentError, 'no block provided' unless block_given? clients.each &block self end |
- (Object) next_client
Raises an error, because it is up to subclasses to define this behavior.
19 20 21 |
# File 'lib/onstomp/failover/pools/base.rb', line 19 def next_client raise 'implemented in subclasses' end |
- (Object) shuffle!
Shuffles the client pool.
24 25 26 |
# File 'lib/onstomp/failover/pools/base.rb', line 24 def shuffle! clients.shuffle! end |