Class: ActiveJob::Retry::ExponentialBackoffStrategy
- Inherits:
-
ConstantBackoffStrategy
- Object
- ConstantBackoffStrategy
- ActiveJob::Retry::ExponentialBackoffStrategy
- Defined in:
- lib/active_job/retry/exponential_backoff_strategy.rb
Instance Method Summary collapse
-
#initialize(options) ⇒ ExponentialBackoffStrategy
constructor
A new instance of ExponentialBackoffStrategy.
- #retry_delay(attempt, _exception) ⇒ Object
Methods inherited from ConstantBackoffStrategy
Constructor Details
#initialize(options) ⇒ ExponentialBackoffStrategy
Returns a new instance of ExponentialBackoffStrategy.
6 7 8 9 10 11 |
# File 'lib/active_job/retry/exponential_backoff_strategy.rb', line 6 def initialize() ExponentialOptionsValidator.new().validate! @retry_limit = .fetch(:limit, 1) @fatal_exceptions = .fetch(:fatal_exceptions, []) @retryable_exceptions = .fetch(:retryable_exceptions, nil) end |
Instance Method Details
#retry_delay(attempt, _exception) ⇒ Object
13 14 15 |
# File 'lib/active_job/retry/exponential_backoff_strategy.rb', line 13 def retry_delay(attempt, _exception) (attempt**4 + 15 + (rand(30) * (attempt + 1))).seconds end |