Class: ActiveJob::QueueAdapters::QueAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/active_job/queue_adapters/que_adapter.rb

Overview

Que adapter for Active Job

Que is a high-performance alternative to DelayedJob or QueueClassic that improves the reliability of your application by protecting your jobs with the same ACID guarantees as the rest of your data. Que is a queue for Ruby and PostgreSQL that manages jobs using advisory locks.

Read more about Que here.

To use Que set the queue_adapter config to :que.

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

Defined Under Namespace

Classes: JobWrapper

Instance Method Summary collapse

Instance Method Details

#enqueue(job) ⇒ Object

:nodoc:



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/active_job/queue_adapters/que_adapter.rb', line 20

def enqueue(job) # :nodoc:
  job_options = { priority: job.priority, queue: job.queue_name }
  que_job = nil

  if require_job_options_kwarg?
    que_job = JobWrapper.enqueue job.serialize, job_options: job_options
  else
    que_job = JobWrapper.enqueue job.serialize, **job_options
  end

  job.provider_job_id = que_job.attrs["job_id"]
  que_job
end

#enqueue_at(job, timestamp) ⇒ Object

:nodoc:



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/active_job/queue_adapters/que_adapter.rb', line 34

def enqueue_at(job, timestamp) # :nodoc:
  job_options = { priority: job.priority, queue: job.queue_name, run_at: Time.at(timestamp) }
  que_job = nil

  if require_job_options_kwarg?
    que_job = JobWrapper.enqueue job.serialize, job_options: job_options
  else
    que_job = JobWrapper.enqueue job.serialize, **job_options
  end

  job.provider_job_id = que_job.attrs["job_id"]
  que_job
end