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
-
#clients ⇒ Object
readonly
Returns the value of attribute clients.
Instance Method Summary collapse
-
#each {|client| ... } ⇒ self
Yields each client in the pool to the supplied block.
-
#initialize(uris) ⇒ Base
constructor
Creates a new client pool by mapping an array of URIs into an array of clients.
-
#next_client ⇒ Object
Raises an error, because it is up to subclasses to define this behavior.
-
#shuffle! ⇒ Object
Shuffles the client pool.
Constructor Details
Instance Attribute Details
#clients ⇒ Object (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
#each {|client| ... } ⇒ self
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 |
#next_client ⇒ Object
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 |
#shuffle! ⇒ Object
Shuffles the client pool.
24 25 26 |
# File 'lib/onstomp/failover/pools/base.rb', line 24 def shuffle! clients.shuffle! end |