Class: Floe::Workflow::Retrier
- Inherits:
-
Object
- Object
- Floe::Workflow::Retrier
- Includes:
- ValidationMixin, ErrorMatcherMixin
- Defined in:
- lib/floe/workflow/retrier.rb
Instance Attribute Summary collapse
-
#backoff_rate ⇒ Object
readonly
Returns the value of attribute backoff_rate.
-
#error_equals ⇒ Object
readonly
Returns the value of attribute error_equals.
-
#interval_seconds ⇒ Object
readonly
Returns the value of attribute interval_seconds.
-
#max_attempts ⇒ Object
readonly
Returns the value of attribute max_attempts.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(_workflow, name, payload) ⇒ Retrier
constructor
A new instance of Retrier.
- #sleep_duration(attempt) ⇒ Object
Methods included from ValidationMixin
included, #invalid_field_error!, #missing_field_error!, #parser_error!, #runtime_field_error!, #workflow_state?, #wrap_parser_error
Methods included from ErrorMatcherMixin
Constructor Details
#initialize(_workflow, name, payload) ⇒ Retrier
Returns a new instance of Retrier.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/floe/workflow/retrier.rb', line 11 def initialize(_workflow, name, payload) @name = name @payload = payload @error_equals = payload["ErrorEquals"] @interval_seconds = payload["IntervalSeconds"] || 1.0 @max_attempts = payload["MaxAttempts"] || 3 @backoff_rate = payload["BackoffRate"] || 2.0 missing_field_error!("ErrorEquals") if !@error_equals.kind_of?(Array) || @error_equals.empty? end |
Instance Attribute Details
#backoff_rate ⇒ Object (readonly)
Returns the value of attribute backoff_rate.
9 10 11 |
# File 'lib/floe/workflow/retrier.rb', line 9 def backoff_rate @backoff_rate end |
#error_equals ⇒ Object (readonly)
Returns the value of attribute error_equals.
9 10 11 |
# File 'lib/floe/workflow/retrier.rb', line 9 def error_equals @error_equals end |
#interval_seconds ⇒ Object (readonly)
Returns the value of attribute interval_seconds.
9 10 11 |
# File 'lib/floe/workflow/retrier.rb', line 9 def interval_seconds @interval_seconds end |
#max_attempts ⇒ Object (readonly)
Returns the value of attribute max_attempts.
9 10 11 |
# File 'lib/floe/workflow/retrier.rb', line 9 def max_attempts @max_attempts end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/floe/workflow/retrier.rb', line 9 def name @name end |
Instance Method Details
#sleep_duration(attempt) ⇒ Object
24 25 26 |
# File 'lib/floe/workflow/retrier.rb', line 24 def sleep_duration(attempt) interval_seconds * (backoff_rate**(attempt - 1)) end |