Class: Desiru::Jobs::RetryStrategies::LinearBackoff
- Inherits:
-
Object
- Object
- Desiru::Jobs::RetryStrategies::LinearBackoff
- Defined in:
- lib/desiru/jobs/retry_strategies.rb
Overview
Linear backoff strategy
Instance Attribute Summary collapse
-
#base_delay ⇒ Object
readonly
Returns the value of attribute base_delay.
-
#increment ⇒ Object
readonly
Returns the value of attribute increment.
-
#max_delay ⇒ Object
readonly
Returns the value of attribute max_delay.
Instance Method Summary collapse
- #delay_for(retry_count) ⇒ Object
-
#initialize(base_delay: 1, max_delay: 60, increment: 5) ⇒ LinearBackoff
constructor
A new instance of LinearBackoff.
Constructor Details
#initialize(base_delay: 1, max_delay: 60, increment: 5) ⇒ LinearBackoff
Returns a new instance of LinearBackoff.
38 39 40 41 42 |
# File 'lib/desiru/jobs/retry_strategies.rb', line 38 def initialize(base_delay: 1, max_delay: 60, increment: 5) @base_delay = base_delay @max_delay = max_delay @increment = increment end |
Instance Attribute Details
#base_delay ⇒ Object (readonly)
Returns the value of attribute base_delay.
36 37 38 |
# File 'lib/desiru/jobs/retry_strategies.rb', line 36 def base_delay @base_delay end |
#increment ⇒ Object (readonly)
Returns the value of attribute increment.
36 37 38 |
# File 'lib/desiru/jobs/retry_strategies.rb', line 36 def increment @increment end |
#max_delay ⇒ Object (readonly)
Returns the value of attribute max_delay.
36 37 38 |
# File 'lib/desiru/jobs/retry_strategies.rb', line 36 def max_delay @max_delay end |
Instance Method Details
#delay_for(retry_count) ⇒ Object
44 45 46 |
# File 'lib/desiru/jobs/retry_strategies.rb', line 44 def delay_for(retry_count) [base_delay + (increment * retry_count), max_delay].min end |