Class: ManageIQ::Floe::Workflow::Retrier

Inherits:
Object
  • Object
show all
Defined in:
lib/manageiq/floe/workflow/retrier.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(payload) ⇒ Retrier

Returns a new instance of Retrier.



9
10
11
12
13
14
15
16
# File 'lib/manageiq/floe/workflow/retrier.rb', line 9

def initialize(payload)
  @payload = payload

  @error_equals     = payload["ErrorEquals"]
  @interval_seconds = payload["IntervalSeconds"] || 1.0
  @max_attempts     = payload["MaxAttempts"] || 3
  @backoff_rate     = payload["BackoffRate"] || 2.0
end

Instance Attribute Details

#backoff_rateObject (readonly)

Returns the value of attribute backoff_rate.



7
8
9
# File 'lib/manageiq/floe/workflow/retrier.rb', line 7

def backoff_rate
  @backoff_rate
end

#error_equalsObject (readonly)

Returns the value of attribute error_equals.



7
8
9
# File 'lib/manageiq/floe/workflow/retrier.rb', line 7

def error_equals
  @error_equals
end

#interval_secondsObject (readonly)

Returns the value of attribute interval_seconds.



7
8
9
# File 'lib/manageiq/floe/workflow/retrier.rb', line 7

def interval_seconds
  @interval_seconds
end

#max_attemptsObject (readonly)

Returns the value of attribute max_attempts.



7
8
9
# File 'lib/manageiq/floe/workflow/retrier.rb', line 7

def max_attempts
  @max_attempts
end

Instance Method Details

#sleep_duration(attempt) ⇒ Object



18
19
20
# File 'lib/manageiq/floe/workflow/retrier.rb', line 18

def sleep_duration(attempt)
  interval_seconds * (backoff_rate * attempt)
end