1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/lib/active_job/queue_adapters/resque_adapter.rb

37 lines
783 B
Ruby
Raw Normal View History

require 'resque'
2014-05-19 06:34:27 -04:00
require 'active_support/core_ext/enumerable'
require 'active_support/core_ext/array/access'
require 'resque_scheduler'
2014-05-18 06:32:22 -04:00
module ActiveJob
module QueueAdapters
class ResqueAdapter
2014-05-18 06:32:22 -04:00
class << self
def enqueue(job, *args)
Resque.enqueue JobWrapper.new(job), job, *args
2014-05-19 06:34:27 -04:00
end
def enqueue_at(job, timestamp, *args)
Resque.enqueue_at timestamp, JobWrapper.new(job), job, *args
end
2014-05-19 06:34:27 -04:00
end
class JobWrapper
class << self
def perform(job_name, *args)
job_name.constantize.new.execute *args
2014-05-19 06:34:27 -04:00
end
end
def initialize(job)
@queue = job.queue_name
end
def to_s
self.class.name
2014-05-18 06:32:22 -04:00
end
end
end
end
end