Sha256: 98f6ba4879571c480e5afdbdcbdf7b5696b43f7182241e4e6e1e8d98eda575b2

Contents?: true

Size: 1.11 KB

Versions: 5

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

module Zenaton
  module Contexts
    # 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.
    class Task
      # @return [String] The UUID identifying the current task
      attr_reader :id

      # @return [Integer] The number of times this task has been automatically
      #   retried. This counter is reset if you issue a manual retry from your
      #   dashboard
      attr_reader :retry_index

      # @return [Zenaton::Contexts::Task] a new execution context for a task
      def initialize(**kwargs)
        @id = kwargs[:id]
        @retry_index = kwargs[:retry_index]
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
zenaton-0.6.0 lib/zenaton/contexts/task.rb
zenaton-0.5.3 lib/zenaton/contexts/task.rb
zenaton-0.5.2 lib/zenaton/contexts/task.rb
zenaton-0.5.1 lib/zenaton/contexts/task.rb
zenaton-0.5.0 lib/zenaton/contexts/task.rb