Class: Philiprehberger::RetryKit::Executor

Inherits:
Object
  • Object
show all
Defined in:
lib/philiprehberger/retry_kit/executor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**options) ⇒ Executor

Returns a new instance of Executor.



8
9
10
11
12
# File 'lib/philiprehberger/retry_kit/executor.rb', line 8

def initialize(**options)
  assign_options(options)
  @last_attempts = 0
  @last_total_delay = 0.0
end

Instance Attribute Details

#last_attemptsObject (readonly)

Returns the value of attribute last_attempts.



6
7
8
# File 'lib/philiprehberger/retry_kit/executor.rb', line 6

def last_attempts
  @last_attempts
end

#last_total_delayObject (readonly)

Returns the value of attribute last_total_delay.



6
7
8
# File 'lib/philiprehberger/retry_kit/executor.rb', line 6

def last_total_delay
  @last_total_delay
end

Instance Method Details

#call(&block) ⇒ Object

Raises:

  • (ArgumentError)


14
15
16
17
18
19
20
21
22
23
# File 'lib/philiprehberger/retry_kit/executor.rb', line 14

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