Class: Fractor::Workflow::LinearBackoff
- Inherits:
-
RetryStrategy
- Object
- RetryStrategy
- Fractor::Workflow::LinearBackoff
- Defined in:
- lib/fractor/workflow/retry_strategy.rb
Overview
Linear backoff retry strategy
Instance Attribute Summary collapse
-
#increment ⇒ Object
readonly
Returns the value of attribute increment.
-
#initial_delay ⇒ Object
readonly
Returns the value of attribute initial_delay.
Attributes inherited from RetryStrategy
Instance Method Summary collapse
- #delay_for(attempt) ⇒ Object
-
#initialize(initial_delay: 1, increment: 1, **options) ⇒ LinearBackoff
constructor
A new instance of LinearBackoff.
Constructor Details
#initialize(initial_delay: 1, increment: 1, **options) ⇒ LinearBackoff
Returns a new instance of LinearBackoff.
52 53 54 55 56 |
# File 'lib/fractor/workflow/retry_strategy.rb', line 52 def initialize(initial_delay: 1, increment: 1, **) super(**) @initial_delay = initial_delay @increment = increment end |
Instance Attribute Details
#increment ⇒ Object (readonly)
Returns the value of attribute increment.
50 51 52 |
# File 'lib/fractor/workflow/retry_strategy.rb', line 50 def increment @increment end |
#initial_delay ⇒ Object (readonly)
Returns the value of attribute initial_delay.
50 51 52 |
# File 'lib/fractor/workflow/retry_strategy.rb', line 50 def initial_delay @initial_delay end |
Instance Method Details
#delay_for(attempt) ⇒ Object
58 59 60 61 62 63 |
# File 'lib/fractor/workflow/retry_strategy.rb', line 58 def delay_for(attempt) return 0 if attempt <= 1 delay = initial_delay + (increment * (attempt - 2)) cap_delay(delay) end |