aboutsummaryrefslogtreecommitdiffstats
path: root/lib/active_job/queue_adapters
diff options
context:
space:
mode:
authorMike Perham <mperham@gmail.com>2014-05-19 21:08:18 -0700
committerMike Perham <mperham@gmail.com>2014-05-19 21:08:18 -0700
commitc813a30c5a3031108bdd41b57571803c13f95569 (patch)
tree93152ba6f30cf572c4f4813a03a0876f7e7c1178 /lib/active_job/queue_adapters
parentc6925f52d07a01c2b729a70bac60b11f7e514d76 (diff)
downloadrails-c813a30c5a3031108bdd41b57571803c13f95569.tar.gz
rails-c813a30c5a3031108bdd41b57571803c13f95569.tar.bz2
rails-c813a30c5a3031108bdd41b57571803c13f95569.zip
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.
Diffstat (limited to 'lib/active_job/queue_adapters')
-rw-r--r--lib/active_job/queue_adapters/sidekiq_adapter.rb11
1 files changed, 9 insertions, 2 deletions
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