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

37 lines
1.1 KiB
Ruby
Raw Normal View History

2017-07-09 13:49:52 -04:00
# frozen_string_literal: true
require "backburner"
2014-05-20 07:03:46 -04:00
module ActiveJob
module QueueAdapters
2014-09-21 16:20:23 -04:00
# == 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}[https://github.com/nesquena/backburner].
#
# To use Backburner set the queue_adapter config to +:backburner+.
#
# Rails.application.config.active_job.queue_adapter = :backburner
2014-05-20 07:03:46 -04:00
class BackburnerAdapter
def enqueue(job) #:nodoc:
Backburner::Worker.enqueue(JobWrapper, [job.serialize], queue: job.queue_name, pri: job.priority)
end
2014-05-20 12:13:28 -04:00
def enqueue_at(job, timestamp) #:nodoc:
delay = timestamp - Time.current.to_f
Backburner::Worker.enqueue(JobWrapper, [job.serialize], queue: job.queue_name, pri: job.priority, delay: delay)
end
2014-05-20 07:03:46 -04:00
class JobWrapper #:nodoc:
2014-05-20 07:03:46 -04:00
class << self
2014-08-25 10:34:50 -04:00
def perform(job_data)
Base.execute job_data
2014-05-20 07:03:46 -04:00
end
end
end
end
end
end