Class: Cosmo::ActiveJobAdapter::Executor

Inherits:
Object
  • Object
show all
Includes:
Job
Defined in:
lib/cosmo/active_job/executor.rb,
sig/cosmo/active_job/executor.rbs

Overview

Cosmo::Job that deserializes and executes an ActiveJob payload

Instance Attribute Summary

Attributes included from Job

#attempt, #batch_id, #enqueued_at, #jid, #scheduled_by

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Job

included, #logger

Class Method Details

.retry_in(data) ⇒ Proc?

Resolves retry_in from the underlying ActiveJob class (declared via cosmo_options), since the processor only ever sees Executor as the worker class for ActiveJob-dispatched jobs.

Parameters:

  • data (Hash[Symbol, untyped])

Returns:

  • (Proc, nil)


13
14
15
16
17
18
# File 'lib/cosmo/active_job/executor.rb', line 13

def self.retry_in(data)
  job_class = Utils::String.safe_constantize(data.dig(:args, 0, :job_class))
  return super unless job_class.respond_to?(:get_cosmo_options)

  job_class.get_cosmo_options[:retry_in] || super
end

Instance Method Details

#perform(job_data) ⇒ void

This method returns an undefined value.

Parameters:

  • job_data (Hash[Symbol, untyped])


20
21
22
# File 'lib/cosmo/active_job/executor.rb', line 20

def perform(job_data)
  ::ActiveJob::Base.execute(Utils::Hash.stringify_keys(job_data))
end