Class: UberTask::RetryInfo
- Inherits:
-
Object
- Object
- UberTask::RetryInfo
- Defined in:
- lib/uber_task/retry_info.rb
Instance Attribute Summary collapse
-
#default_retries ⇒ Object
readonly
Returns the value of attribute default_retries.
-
#default_retry_wait ⇒ Object
readonly
Returns the value of attribute default_retry_wait.
-
#report ⇒ Object
Returns the value of attribute report.
-
#retries ⇒ Object
readonly
Returns the value of attribute retries.
-
#retries_remaining ⇒ Object
Returns the value of attribute retries_remaining.
-
#wait ⇒ Object
Returns the value of attribute wait.
Instance Method Summary collapse
-
#initialize(default_retries: nil, default_retry_wait: nil, retries: nil) ⇒ RetryInfo
constructor
A new instance of RetryInfo.
- #message(wait: nil) ⇒ Object
Constructor Details
#initialize(default_retries: nil, default_retry_wait: nil, retries: nil) ⇒ RetryInfo
Returns a new instance of RetryInfo.
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/uber_task/retry_info.rb', line 13 def initialize( default_retries: nil, default_retry_wait: nil, retries: nil ) @default_retries = default_retries || 0 @default_retry_wait = default_retry_wait || 0 @report = true @retries = retries || 0 @retries_remaining = retries || 0 @wait = 0 end |
Instance Attribute Details
#default_retries ⇒ Object (readonly)
Returns the value of attribute default_retries.
9 10 11 |
# File 'lib/uber_task/retry_info.rb', line 9 def default_retries @default_retries end |
#default_retry_wait ⇒ Object (readonly)
Returns the value of attribute default_retry_wait.
9 10 11 |
# File 'lib/uber_task/retry_info.rb', line 9 def default_retry_wait @default_retry_wait end |
#report ⇒ Object
Returns the value of attribute report.
5 6 7 |
# File 'lib/uber_task/retry_info.rb', line 5 def report @report end |
#retries ⇒ Object (readonly)
Returns the value of attribute retries.
9 10 11 |
# File 'lib/uber_task/retry_info.rb', line 9 def retries @retries end |
#retries_remaining ⇒ Object
Returns the value of attribute retries_remaining.
5 6 7 |
# File 'lib/uber_task/retry_info.rb', line 5 def retries_remaining @retries_remaining end |
#wait ⇒ Object
Returns the value of attribute wait.
5 6 7 |
# File 'lib/uber_task/retry_info.rb', line 5 def wait @wait end |
Instance Method Details
#message(wait: nil) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/uber_task/retry_info.rb', line 26 def (wait: nil) if wait.nil? wait = @wait end if wait < 1 wait = default_retry_wait || 0 end if wait.positive? " Retrying in \#{wait} seconds... (\#{retries_remaining} retries remaining)\n MSG\n else\n <<~MSG.strip\n Retrying... (\#{retries_remaining} retries remaining)\n MSG\n end\nend\n".strip |