Class: Philiprehberger::RetryKit::Executor
- Inherits:
-
Object
- Object
- Philiprehberger::RetryKit::Executor
- Defined in:
- lib/philiprehberger/retry_kit/executor.rb
Constant Summary collapse
- VALID_BACKOFFS =
%i[exponential linear constant].freeze
- VALID_JITTERS =
%i[full equal none decorrelated].freeze
Instance Attribute Summary collapse
-
#last_attempts ⇒ Object
readonly
Returns the value of attribute last_attempts.
-
#last_total_delay ⇒ Object
readonly
Returns the value of attribute last_total_delay.
Instance Method Summary collapse
- #call(&block) ⇒ Object
-
#initialize(**options) ⇒ Executor
constructor
A new instance of Executor.
Constructor Details
#initialize(**options) ⇒ Executor
Returns a new instance of Executor.
11 12 13 14 15 16 |
# File 'lib/philiprehberger/retry_kit/executor.rb', line 11 def initialize(**) () @last_attempts = 0 @last_total_delay = 0.0 end |
Instance Attribute Details
#last_attempts ⇒ Object (readonly)
Returns the value of attribute last_attempts.
9 10 11 |
# File 'lib/philiprehberger/retry_kit/executor.rb', line 9 def last_attempts @last_attempts end |
#last_total_delay ⇒ Object (readonly)
Returns the value of attribute last_total_delay.
9 10 11 |
# File 'lib/philiprehberger/retry_kit/executor.rb', line 9 def last_total_delay @last_total_delay end |
Instance Method Details
#call(&block) ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/philiprehberger/retry_kit/executor.rb', line 18 def call(&block) raise ArgumentError, 'Block required' unless block @last_attempts = 0 @last_total_delay = 0.0 @last_decorrelated_delay = @base_delay @start_time = @total_timeout ? Process.clock_gettime(Process::CLOCK_MONOTONIC) : nil attempt_with_retries(0, &block) end |