Class: Zenaton::Contexts::Task
- Inherits:
-
Object
- Object
- Zenaton::Contexts::Task
- Defined in:
- lib/zenaton/contexts/task.rb
Overview
Represents the current runtime context of a Task.
The information provided by the context can be useful to alter the behaviour of the task.
For example, you can use the attempt index to know if a task has been automatically retried or not and how many times, and decide to do something when you did not expect the task to be retried more than X times.
You can also use the attempt number in the ‘on_error_retry_delay` method of a task in order to implement complex retry strategies.
Instance Attribute Summary collapse
-
#id ⇒ String
readonly
The UUID identifying the current task.
-
#retry_index ⇒ Integer
readonly
The number of times this task has been automatically retried.
Instance Method Summary collapse
-
#initialize(**kwargs) ⇒ Zenaton::Contexts::Task
constructor
A new execution context for a task.
Constructor Details
#initialize(**kwargs) ⇒ Zenaton::Contexts::Task
Returns a new execution context for a task.
27 28 29 30 |
# File 'lib/zenaton/contexts/task.rb', line 27 def initialize(**kwargs) @id = kwargs[:id] @retry_index = kwargs[:retry_index] end |
Instance Attribute Details
#id ⇒ String (readonly)
Returns The UUID identifying the current task.
19 20 21 |
# File 'lib/zenaton/contexts/task.rb', line 19 def id @id end |
#retry_index ⇒ Integer (readonly)
Returns The number of times this task has been automatically retried. This counter is reset if you issue a manual retry from your dashboard.
24 25 26 |
# File 'lib/zenaton/contexts/task.rb', line 24 def retry_index @retry_index end |