Module: ActiveJob::Retry::ClassMethods
- Defined in:
- lib/active_job/retry.rb
Overview
Configuration #
Instance Attribute Summary collapse
-
#backoff_strategy ⇒ Object
readonly
Returns the value of attribute backoff_strategy.
Instance Method Summary collapse
- #backoff_strategy_valid?(backoff_strategy) ⇒ Boolean
- #constant_retry(options) ⇒ Object
- #exponential_retry(options) ⇒ Object
- #retry_with(backoff_strategy) ⇒ Object
- #variable_retry(options) ⇒ Object
Instance Attribute Details
#backoff_strategy ⇒ Object (readonly)
Returns the value of attribute backoff_strategy.
39 40 41 |
# File 'lib/active_job/retry.rb', line 39 def backoff_strategy @backoff_strategy end |
Instance Method Details
#backoff_strategy_valid?(backoff_strategy) ⇒ Boolean
63 64 65 66 67 68 |
# File 'lib/active_job/retry.rb', line 63 def backoff_strategy_valid?(backoff_strategy) backoff_strategy.respond_to?(:should_retry?) && backoff_strategy.respond_to?(:retry_delay) && backoff_strategy.method(:should_retry?).arity == 2 && backoff_strategy.method(:retry_delay).arity == 2 end |
#constant_retry(options) ⇒ Object
41 42 43 |
# File 'lib/active_job/retry.rb', line 41 def constant_retry() retry_with(ConstantBackoffStrategy.new()) end |
#exponential_retry(options) ⇒ Object
49 50 51 |
# File 'lib/active_job/retry.rb', line 49 def exponential_retry() retry_with(ExponentialBackoffStrategy.new()) end |
#retry_with(backoff_strategy) ⇒ Object
53 54 55 56 57 58 59 60 61 |
# File 'lib/active_job/retry.rb', line 53 def retry_with(backoff_strategy) unless backoff_strategy_valid?(backoff_strategy) raise InvalidConfigurationError, 'Backoff strategies must define `should_retry?(attempt, exception)`, ' \ 'and `retry_delay(attempt, exception)`.' end @backoff_strategy = backoff_strategy end |
#variable_retry(options) ⇒ Object
45 46 47 |
# File 'lib/active_job/retry.rb', line 45 def variable_retry() retry_with(VariableBackoffStrategy.new()) end |