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/que_adapter.rb

34 lines
1,021 B
Ruby
Raw Normal View History

2014-05-19 14:09:45 -04:00
require 'que'
module ActiveJob
module QueueAdapters
2014-09-21 16:20:23 -04:00
# == 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}[https://github.com/chanks/que].
#
# To use Que set the queue_adapter config to +:que+.
#
# Rails.application.config.active_job.queue_adapter = :que
2014-05-19 14:09:45 -04:00
class QueAdapter
def enqueue(job) #:nodoc:
JobWrapper.enqueue job.serialize, queue: job.queue_name
end
def enqueue_at(job, timestamp) #:nodoc:
JobWrapper.enqueue job.serialize, queue: job.queue_name, run_at: Time.at(timestamp)
2014-05-19 14:09:45 -04:00
end
class JobWrapper < Que::Job #:nodoc:
2014-08-25 10:34:50 -04:00
def run(job_data)
Base.execute job_data
2014-05-19 14:09:45 -04:00
end
end
end
end
end