Module: Rage::Deferred::Task

Included in:
Proxy::Wrapper
Defined in:
lib/rage/deferred/task.rb

Overview

Rage::Deferred::Task is a module that should be included in classes that represent tasks to be executed in the background by the Rage::Deferred queue. It ensures the tasks can be retried in case of a failure, with a maximum number of attempts and an exponential backoff strategy.

To define a task, include the module and implement the #perform method:

class ProcessImage
  include Rage::Deferred::Task

  def perform(image_path:)
    # logic to process the image
  end
end

The task can be enqueued using the enqueue method:

ProcessImage.enqueue(image_path: 'path/to/image.jpg')

The delay and delay_until options can be used to specify when the task should be executed.

ProcessImage.enqueue(image_path: 'path/to/image.jpg', delay: 10) # delays execution by 10 seconds
ProcessImage.enqueue(image_path: 'path/to/image.jpg', delay_until: Time.now + 3600) # executes after 1 hour

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#performObject



40
41
# File 'lib/rage/deferred/task.rb', line 40

def perform
end