class Cottus::RetryableRoundRobinStrategy
Public Class Methods
new(connections, options={})
click to toggle source
Calls superclass method
Cottus::RoundRobinStrategy::new
# File lib/cottus/strategies.rb, line 58 def initialize(connections, options={}) super @timeouts = options[:timeouts] || [1, 3, 5] end
Public Instance Methods
execute(meth, path, options={})
click to toggle source
# File lib/cottus/strategies.rb, line 64 def execute(meth, path, options={}) tries = 0 starting_connection = connection = next_connection begin connection.send(meth, path, options) rescue *VALID_EXCEPTIONS => e if tries < @timeouts.size sleep @timeouts[tries] tries += 1 retry else connection = next_connection raise e if connection == starting_connection tries = 0 retry end end end