From c813a30c5a3031108bdd41b57571803c13f95569 Mon Sep 17 00:00:00 2001 From: Mike Perham Date: Mon, 19 May 2014 21:08:18 -0700 Subject: Reimplement Sidekiq worker This better integrates various Sidekiq features into AJ jobs. Things like the JID will be set as expected and the user can use `sidekiq_options` in AJ::Base subclasses as usual to configure various features. --- lib/active_job/queue_adapters/sidekiq_adapter.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/active_job/queue_adapters/sidekiq_adapter.rb b/lib/active_job/queue_adapters/sidekiq_adapter.rb index c8fac32963..087e833d24 100644 --- a/lib/active_job/queue_adapters/sidekiq_adapter.rb +++ b/lib/active_job/queue_adapters/sidekiq_adapter.rb @@ -5,7 +5,8 @@ module ActiveJob class SidekiqAdapter class << self def queue(job, *args) - JobWrapper.client_push class: JobWrapper, queue: job.queue_name, args: [ job, *args ] + item = { 'class' => JobWrapper, 'queue' => job.queue_name, 'args' => [job, *args] } + Sidekiq::Client.push(job.get_sidekiq_options.merge(item)) end end @@ -13,9 +14,15 @@ module ActiveJob include Sidekiq::Worker def perform(job_name, *args) - job_name.constantize.new.perform *Parameters.deserialize(args) + instance = job_name.constantize.new + instance.jid = self.jid + instance.perform *Parameters.deserialize(args) end end end end end + +class ActiveJob::Base + include Sidekiq::Worker +end -- cgit v1.2.3