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

27 lines
617 B
Ruby
Raw Normal View History

2014-05-20 07:03:46 -04:00
require 'backburner'
module ActiveJob
module QueueAdapters
class BackburnerAdapter
class << self
2014-08-25 10:34:50 -04:00
def enqueue(job)
Backburner::Worker.enqueue JobWrapper, [ job.serialize ], queue: job.queue_name
2014-05-20 07:03:46 -04:00
end
2014-05-20 12:13:28 -04:00
2014-08-25 10:34:50 -04:00
def enqueue_at(job, timestamp)
2014-08-29 17:04:01 -04:00
delay = timestamp - Time.current.to_f
2014-08-25 10:34:50 -04:00
Backburner::Worker.enqueue JobWrapper, [ job.serialize ], queue: job.queue_name, delay: delay
2014-05-20 12:13:28 -04:00
end
end
2014-05-20 07:03:46 -04:00
class JobWrapper
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