2014-06-12 04:14:42 -04:00
|
|
|
require 'qu'
|
|
|
|
|
|
|
|
module ActiveJob
|
|
|
|
module QueueAdapters
|
|
|
|
class QuAdapter
|
|
|
|
class << self
|
|
|
|
def enqueue(job, *args)
|
2014-08-06 17:09:28 -04:00
|
|
|
Qu::Payload.new(klass: JobWrapper, args: [job.name, *args]).tap do |payload|
|
|
|
|
payload.instance_variable_set(:@queue, job.queue_name)
|
|
|
|
end.push
|
2014-06-12 04:14:42 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def enqueue_at(job, timestamp, *args)
|
|
|
|
raise NotImplementedError
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class JobWrapper < Qu::Job
|
2014-08-06 17:09:28 -04:00
|
|
|
def initialize(job_name, *args)
|
|
|
|
@job = job_name.constantize
|
2014-06-12 04:14:42 -04:00
|
|
|
@args = args
|
|
|
|
end
|
|
|
|
|
|
|
|
def perform
|
2014-08-18 09:09:04 -04:00
|
|
|
@job.new.execute(*@args)
|
2014-06-12 04:14:42 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|