Class: ActiveJob::QueueAdapters::BackburnerAdapter

Inherits:
AbstractAdapter show all
Defined in:
lib/active_job/queue_adapters/backburner_adapter.rb

Overview

Backburner adapter for Active Job

Backburner is a beanstalkd-powered job queue that can handle a very high volume of jobs. You create background jobs and place them on multiple work queues to be processed later. Read more about Backburner here.

To use Backburner set the queue_adapter config to :backburner.

Rails.application.config.active_job.queue_adapter = :backburner

Defined Under Namespace

Classes: JobWrapper

Instance Method Summary collapse

Instance Method Details

#enqueue(job) ⇒ Object

:nodoc:



18
19
20
21
22
# File 'lib/active_job/queue_adapters/backburner_adapter.rb', line 18

def enqueue(job) # :nodoc:
  response = Backburner::Worker.enqueue(JobWrapper, [job.serialize], queue: job.queue_name, pri: job.priority)
  job.provider_job_id = response[:id] if response.is_a?(Hash)
  response
end

#enqueue_at(job, timestamp) ⇒ Object

:nodoc:



24
25
26
27
28
29
# File 'lib/active_job/queue_adapters/backburner_adapter.rb', line 24

def enqueue_at(job, timestamp) # :nodoc:
  delay = timestamp - Time.current.to_f
  response = Backburner::Worker.enqueue(JobWrapper, [job.serialize], queue: job.queue_name, pri: job.priority, delay: delay)
  job.provider_job_id = response[:id] if response.is_a?(Hash)
  response
end