aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activejob/CHANGELOG.md5
-rw-r--r--activejob/lib/active_job/queue_adapters/sidekiq_adapter.rb8
-rw-r--r--activejob/test/integration/queuing_test.rb10
3 files changed, 21 insertions, 2 deletions
diff --git a/activejob/CHANGELOG.md b/activejob/CHANGELOG.md
index 6f9aa76a1f..9c5806a4db 100644
--- a/activejob/CHANGELOG.md
+++ b/activejob/CHANGELOG.md
@@ -1,3 +1,8 @@
+* Allow `Sidekiq` to report the job id back to `ActiveJob::Base` as
+ `provider_job_id`
+
+ *Jeroen van Baarsen*
+
* Allow `DelayedJob` to report id back to `ActiveJob::Base` as
`provider_job_id`.
diff --git a/activejob/lib/active_job/queue_adapters/sidekiq_adapter.rb b/activejob/lib/active_job/queue_adapters/sidekiq_adapter.rb
index 743d5ea333..7a2dd3e9fc 100644
--- a/activejob/lib/active_job/queue_adapters/sidekiq_adapter.rb
+++ b/activejob/lib/active_job/queue_adapters/sidekiq_adapter.rb
@@ -17,20 +17,24 @@ module ActiveJob
class SidekiqAdapter
def enqueue(job) #:nodoc:
#Sidekiq::Client does not support symbols as keys
- Sidekiq::Client.push \
+ sidekiq_job_id = Sidekiq::Client.push \
'class' => JobWrapper,
'wrapped' => job.class.to_s,
'queue' => job.queue_name,
'args' => [ job.serialize ]
+ job.provider_job_id = sidekiq_job_id
+ sidekiq_job_id
end
def enqueue_at(job, timestamp) #:nodoc:
- Sidekiq::Client.push \
+ sidekiq_job_id = Sidekiq::Client.push \
'class' => JobWrapper,
'wrapped' => job.class.to_s,
'queue' => job.queue_name,
'args' => [ job.serialize ],
'at' => timestamp
+ job.provider_job_id = sidekiq_job_id
+ sidekiq_job_id
end
class JobWrapper #:nodoc:
diff --git a/activejob/test/integration/queuing_test.rb b/activejob/test/integration/queuing_test.rb
index 403b803558..f2665221b8 100644
--- a/activejob/test/integration/queuing_test.rb
+++ b/activejob/test/integration/queuing_test.rb
@@ -61,4 +61,14 @@ class QueuingTest < ActiveSupport::TestCase
test_job = TestJob.perform_later @id
assert_kind_of Fixnum, test_job.provider_job_id
end
+
+ test 'should supply a provider_job_id to Sidekiq' do
+ skip unless adapter_is?(:sidekiq)
+ test_job = TestJob.perform_later @id
+ refute test_job.provider_job_id.nil?, "Provider job id should be set by Sidekiq"
+
+ delayed_test_job = TestJob.set(wait: 1.minute).perform_later @id
+ refute delayed_test_job.provider_job_id.nil?,
+ "Provider job id should by set for delayed jobs by sidekiq"
+ end
end