Class: ActiveJob::QueueAdapters::ResqueAdapter

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

Overview

Resque adapter for Active Job

Resque (pronounced like “rescue”) is a Redis-backed library for creating background jobs, placing those jobs on multiple queues, and processing them later.

Read more about Resque here.

To use Resque set the queue_adapter config to :resque.

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

Defined Under Namespace

Classes: JobWrapper

Instance Method Summary collapse

Instance Method Details

#enqueue(job) ⇒ Object

:nodoc:


29
30
31
32
# File 'activejob/lib/active_job/queue_adapters/resque_adapter.rb', line 29

def enqueue(job) #:nodoc:
  JobWrapper.instance_variable_set(:@queue, job.queue_name)
  Resque.enqueue_to job.queue_name, JobWrapper, job.serialize
end

#enqueue_at(job, timestamp) ⇒ Object

:nodoc:


34
35
36
37
38
39
40
# File 'activejob/lib/active_job/queue_adapters/resque_adapter.rb', line 34

def enqueue_at(job, timestamp) #:nodoc:
  unless Resque.respond_to?(:enqueue_at_with_queue)
    raise NotImplementedError, "To be able to schedule jobs with Resque you need the " \
      "resque-scheduler gem. Please add it to your Gemfile and run bundle install"
  end
  Resque.enqueue_at_with_queue job.queue_name, timestamp, JobWrapper, job.serialize
end