Class: ActiveJob::QueueAdapters::WorkerholicAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/workerholic/adapters/active_job_adapter.rb

Defined Under Namespace

Classes: JobWrapper

Instance Method Summary collapse

Instance Method Details

#enqueue(job) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/workerholic/adapters/active_job_adapter.rb', line 4

def enqueue(job)
  job_data = job.serialize
  queue_name = "workerholic:queue:#{job_data['queue_name']}"

  job = JobWrapper.new
  job.instance_variable_set(:@queue_name, queue_name)

  # capture job class so it can be passed to `Base.execute` in `JobWrapper#perform`
  job.instance_variable_set(:@class, job_data['job_class'])

  job.perform_async(*job_data['arguments'])
end