1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activejob/lib/active_job/queue_adapters/qu_adapter.rb
Robin Dupret d63005447b Tiny follow-up to #16999 [ci skip]
* Fix a typo
* Remove references to Rails version
* Remove an extra whitespace
2014-09-27 16:22:15 +02:00

42 lines
1.2 KiB
Ruby

require 'qu'
module ActiveJob
module QueueAdapters
# == Qu adapter for Active Job
#
# Qu is a Ruby library for queuing and processing background jobs. It is
# heavily inspired by delayed_job and Resque. Qu was created to overcome
# some shortcomings in the existing queuing libraries.
# The advantages of Qu are: Multiple backends (redis, mongo), jobs are
# requeued when worker is killed, resque-like API.
#
# Read more about Qu {here}[https://github.com/bkeepers/qu].
#
# To use Qu set the queue_adapter config to +:qu+.
#
# Rails.application.config.active_job.queue_adapter = :qu
class QuAdapter
class << self
def enqueue(job, *args) #:nodoc:
Qu::Payload.new(klass: JobWrapper, args: [job.serialize]).tap do |payload|
payload.instance_variable_set(:@queue, job.queue_name)
end.push
end
def enqueue_at(job, timestamp, *args) #:nodoc:
raise NotImplementedError
end
end
class JobWrapper < Qu::Job #:nodoc:
def initialize(job_data)
@job_data = job_data
end
def perform
Base.execute @job_data
end
end
end
end
end