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
|
2014-05-20 18:26:19 -04:00
|
|
|
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
|