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

36 lines
843 B
Ruby
Raw Normal View History

2014-05-18 15:02:02 -04:00
require 'sidekiq'
module ActiveJob
module QueueAdapters
class SidekiqAdapter
class << self
def enqueue(job, *args)
#Sidekiq::Client does not support symbols as keys
2014-05-20 11:37:10 -04:00
Sidekiq::Client.push \
'class' => JobWrapper,
'queue' => job.queue_name,
'args' => [ job, *args ],
'retry' => true
2014-05-19 06:34:27 -04:00
end
def enqueue_at(job, timestamp, *args)
2014-05-20 12:13:28 -04:00
Sidekiq::Client.push \
'class' => JobWrapper,
'queue' => job.queue_name,
'args' => [ job, *args ],
'retry' => true,
'at' => timestamp
end
2014-05-19 06:34:27 -04:00
end
class JobWrapper
include Sidekiq::Worker
def perform(job_name, *args)
job_name.constantize.new.execute(*args)
2014-05-18 15:02:02 -04:00
end
end
end
end
end