Module: Cosmo::ActiveJobAdapter::Options

Defined in:
lib/cosmo/active_job/options.rb,
sig/cosmo/active_job/options.rbs

Overview

Adds cosmo_options to ActiveJob classes.

class MyJob < ApplicationJob
cosmo_options retry: 5, dead: false, retry_in: ->(count, exception) { count * 30 }

def perform(user_id)
  # ...
end
end

Options mirror those accepted by Cosmo::Job:

retry:    [Integer, Boolean]  Number of retries before giving up (default: 3). +false+ means 0 (no retries)
dead:     [Boolean]  Move to DLQ when retries exhausted? (default: true)
stream:   [Symbol]   Override the NATS stream (default: derived from queue_name)
retry_in: [Proc]     <tt>->(count, exception) { }</tt> computing seconds to wait before redelivering a
        failed job (+count+ is the 1-based delivery attempt that just failed). Falls back to the
        default backoff if unset, non-numeric/non-positive, or raising.

Defined Under Namespace

Modules: ClassMethods

Constant Summary collapse

VALID_OPTIONS =
%i[retry dead stream retry_in].freeze

Class Method Summary collapse

Class Method Details

.included(base) ⇒ void

This method returns an undefined value.

Parameters:

  • base (::Module)


25
26
27
# File 'lib/cosmo/active_job/options.rb', line 25

def self.included(base)
  base.extend(ClassMethods)
end