Class: Cassanity::RetryStrategies::RetryNTimes
- Inherits:
-
RetryStrategy
- Object
- RetryStrategy
- Cassanity::RetryStrategies::RetryNTimes
- Defined in:
- lib/cassanity/retry_strategies/retry_n_times.rb
Instance Attribute Summary collapse
-
#retries ⇒ Object
readonly
Private.
Instance Method Summary collapse
-
#fail(attempts, error) ⇒ Object
Private: re-raise the exception from the last call if it’s been retried more than the maximum allowed amount.
-
#initialize(args = {}) ⇒ RetryNTimes
constructor
Public: initialize the retry strategy.
Methods inherited from RetryStrategy
Constructor Details
#initialize(args = {}) ⇒ RetryNTimes
Public: initialize the retry strategy.
args - The Hash of arguments.
:retries - the number of times to retry an unsuccessful call
before failing.
14 15 16 17 18 |
# File 'lib/cassanity/retry_strategies/retry_n_times.rb', line 14 def initialize(args = {}) # By default, there's no retries - if the call fails, you # get the error propagated to you. @retries = args[:retries] || 0 end |
Instance Attribute Details
#retries ⇒ Object (readonly)
Private
7 8 9 |
# File 'lib/cassanity/retry_strategies/retry_n_times.rb', line 7 def retries @retries end |
Instance Method Details
#fail(attempts, error) ⇒ Object
Private: re-raise the exception from the last call if it’s been retried more than the maximum allowed amount.
22 23 24 25 26 |
# File 'lib/cassanity/retry_strategies/retry_n_times.rb', line 22 def fail(attempts, error) if attempts > @retries raise error end end |