Class: Cottus::RoundRobinStrategy
- Defined in:
- lib/cottus/strategies.rb
Direct Known Subclasses
Instance Method Summary collapse
- #execute(meth, path, options = {}) ⇒ Object
-
#initialize(connections, options = {}) ⇒ RoundRobinStrategy
constructor
A new instance of RoundRobinStrategy.
Constructor Details
#initialize(connections, options = {}) ⇒ RoundRobinStrategy
Returns a new instance of RoundRobinStrategy.
24 25 26 27 28 29 |
# File 'lib/cottus/strategies.rb', line 24 def initialize(connections, ={}) super @index = 0 @mutex = Mutex.new end |
Instance Method Details
#execute(meth, path, options = {}) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/cottus/strategies.rb', line 31 def execute(meth, path, ={}) tries = 0 begin next_connection.send(meth, path, ) rescue *VALID_EXCEPTIONS => e if tries >= @connections.count raise e else tries += 1 retry end end end |