Class: EnqueueMiddlewareInterface

Inherits:
Object
  • Object
show all
Defined in:
lib/rage/configuration.rb

Overview

Note:

This class does not exist at runtime and is used for documentation purposes only. Do not inherit your middleware classes from it.

Instance Method Summary collapse

Instance Method Details

#call(task_class:, delay:, delay_until:, phase:, args:, kwargs:, context:) ⇒ Object

Called whenever a deferred task is enqueued.

The middleware is expected to call yield to pass control to the next middleware in the stack. If the middleware does not call yield, the task will not be enqueued.

Rage automatically detects which parameters your middleware’s #call method accepts, and only passes those parameters. You can omit any of the described parameters in your implementation.

Examples:

class EncryptArgumentsMiddleware
  def call(args:, kwargs:)
    args.map! { |arg| MyEncryptionSDK.encrypt(arg) }
    kwargs.transform_values! { |value| MyEncryptionSDK.encrypt(value) }

    yield
  end
end

Parameters:

  • task_class (Class)

    the deferred task class

  • delay (Integer, nil)

    the delay in seconds before the task is executed

  • delay_until (Time, Integer, nil)

    the time at which the task should be executed

  • phase (:enqueue)

    the middleware phase. Useful for middlewares that are shared between enqueue and perform phases

  • args (Array)

    the positional arguments passed to the task

  • kwargs (Hash)

    the keyword arguments passed to the task

  • context (Hash)

    the context is serialized together with the task and allows passing data between middlewares without exposing it to the task itself



25
26
# File 'lib/rage/configuration.rb', line 25

def call(task_class:, delay:, delay_until:, phase:, args:, kwargs:, context:)
end