class Zenaton::Interfaces::Task
@abstract Subclass and override {#handle} to define your custom tasks
Public Instance Methods
add_context(**attributes)
click to toggle source
@private Sets a new context if none has been set yet. This is called from the zenaton agent and will raise if called twice. @raise [ArgumentError] when the context was already set.
# File lib/zenaton/interfaces/task.rb, line 35 def add_context(**attributes) message = <<~ERROR Context has already been set and cannot be mutated. ERROR raise ArgumentError, message if @context @context = Contexts::Task.new(attributes) end
context()
click to toggle source
@return [Zenaton::Contexts::Task] the task execution context
# File lib/zenaton/interfaces/task.rb, line 27 def context @context || Contexts::Task.new end
handle()
click to toggle source
Child classes should implement the handle method
# File lib/zenaton/interfaces/task.rb, line 11 def handle raise NotImplemented, "Your workflow does not implement the `#handle' method" end
on_error_retry_delay(_exception)
click to toggle source
(Optional) Implement this method for automatic retrial of task in case of failures. @param _exception [Exception] the reason for the task failure. @return [Integer, FalseClass, NilClass] the non-negative amount of
seconds to wait before automatically retrying this task. Falsy values will avoid retrial. Other values will cause the retrial to fail.
# File lib/zenaton/interfaces/task.rb, line 22 def on_error_retry_delay(_exception) nil end