Class: Rage::Deferred::Metadata
- Inherits:
-
Object
- Object
- Rage::Deferred::Metadata
- Defined in:
- lib/rage/deferred/metadata.rb
Overview
Provides metadata about the current deferred task execution.
Class Method Summary collapse
-
.attempts ⇒ Integer
Returns the current attempt number.
-
.retries ⇒ Integer
Returns the number of retries that have occurred for the current task.
-
.retrying? ⇒ Boolean
Checks whether this is a retry execution.
-
.will_retry? ⇒ Boolean
Checks whether the task will be retried if the current execution fails.
-
.will_retry_in ⇒ Numeric?
Returns the number of seconds until the next retry, or
nilif no retry will occur.
Class Method Details
.attempts ⇒ Integer
Returns the current attempt number.
10 11 12 |
# File 'lib/rage/deferred/metadata.rb', line 10 def attempts Rage::Deferred::Context.get_attempts(context).to_i + 1 end |
.retries ⇒ Integer
Returns the number of retries that have occurred for the current task.
16 17 18 |
# File 'lib/rage/deferred/metadata.rb', line 16 def retries attempts - 1 end |
.retrying? ⇒ Boolean
Checks whether this is a retry execution.
22 23 24 |
# File 'lib/rage/deferred/metadata.rb', line 22 def attempts > 1 end |
.will_retry? ⇒ Boolean
Checks whether the task will be retried if the current execution fails.
28 29 30 31 |
# File 'lib/rage/deferred/metadata.rb', line 28 def will_retry? task = Rage::Deferred::Context.get_task(context) !!task.__next_retry_in(attempts, nil) end |
.will_retry_in ⇒ Numeric?
Returns the number of seconds until the next retry, or nil if no retry will occur.
The result is memoized per attempt so that the value reported here matches what the queue uses to schedule the retry.
36 37 38 39 |
# File 'lib/rage/deferred/metadata.rb', line 36 def will_retry_in task = Rage::Deferred::Context.get_task(context) task.__next_retry_in(attempts, nil) end |