Skip to content

Commit 68e3279

Browse files
committed
implement provider_job_id for queue_classic.
The latest, currently unreleased, version of queue_classic is required for this to work. See QueueClassic/queue_classic#262 for more details.
1 parent 0650d08 commit 68e3279

5 files changed

Lines changed: 23 additions & 9 deletions

File tree

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ group :job do
4949
gem 'sidekiq', require: false
5050
gem 'sucker_punch', require: false
5151
gem 'delayed_job', require: false
52-
gem 'queue_classic', require: false, platforms: :ruby
52+
gem 'queue_classic', github: "QueueClassic/queue_classic", require: false, platforms: :ruby
5353
gem 'sneakers', require: false
5454
gem 'que', require: false
5555
gem 'backburner', require: false

Gemfile.lock

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
GIT
2+
remote: git://github.com/QueueClassic/queue_classic.git
3+
revision: d144db29f1436e9e8b3c7a1a1ecd4442316a9ecd
4+
specs:
5+
queue_classic (3.2.0.alpha)
6+
pg (>= 0.17, < 0.19)
7+
18
GIT
29
remote: git://github.com/bkeepers/qu.git
310
revision: d098e2657c92e89a6413bebd9c033930759c061f
@@ -173,8 +180,6 @@ GEM
173180
pg (0.18.2)
174181
psych (2.0.13)
175182
que (0.10.0)
176-
queue_classic (3.1.0)
177-
pg (>= 0.17, < 0.19)
178183
racc (1.4.12)
179184
rack (1.6.4)
180185
rack-cache (1.2)
@@ -289,7 +294,7 @@ DEPENDENCIES
289294
qu-rails!
290295
qu-redis
291296
que
292-
queue_classic
297+
queue_classic!
293298
racc (>= 1.4.6)
294299
rack-cache (~> 1.2)
295300
rails!

activejob/CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1+
* Implement `provider_job_id` for `queue_classic` adapter. This requires the
2+
latest, currently unreleased, version of queue_classic.
3+
4+
*Yves Senn*
5+
16
* `assert_enqueued_with` and `assert_performed_with` now returns the matched
27
job instance for further assertions.
3-
8+
49
*Jean Boussier*
510

611
* Include I18n.locale into job serialization/deserialization and use it around

activejob/lib/active_job/queue_adapters/queue_classic_adapter.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ module QueueAdapters
1818
# Rails.application.config.active_job.queue_adapter = :queue_classic
1919
class QueueClassicAdapter
2020
def enqueue(job) #:nodoc:
21-
build_queue(job.queue_name).enqueue("#{JobWrapper.name}.perform", job.serialize)
21+
qc_job = build_queue(job.queue_name).enqueue("#{JobWrapper.name}.perform", job.serialize)
22+
job.provider_job_id = qc_job["id"] if qc_job.is_a?(Hash)
23+
qc_job
2224
end
2325

2426
def enqueue_at(job, timestamp) #:nodoc:
@@ -28,7 +30,9 @@ def enqueue_at(job, timestamp) #:nodoc:
2830
'the QC::Queue needs to respond to `enqueue_at(timestamp, method, *args)`. ' \
2931
'You can implement this yourself or you can use the queue_classic-later gem.'
3032
end
31-
queue.enqueue_at(timestamp, "#{JobWrapper.name}.perform", job.serialize)
33+
qc_job = queue.enqueue_at(timestamp, "#{JobWrapper.name}.perform", job.serialize)
34+
job.provider_job_id = qc_job["id"] if qc_job.is_a?(Hash)
35+
qc_job
3236
end
3337

3438
# Builds a <tt>QC::Queue</tt> object to schedule jobs on.

activejob/test/integration/queuing_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ class QueuingTest < ActiveSupport::TestCase
5757
end
5858

5959
test 'should supply a provider_job_id when available for immediate jobs' do
60-
skip unless adapter_is?(:delayed_job, :sidekiq, :qu, :que)
60+
skip unless adapter_is?(:delayed_job, :sidekiq, :qu, :que, :queue_classic)
6161
test_job = TestJob.perform_later @id
6262
assert test_job.provider_job_id, 'Provider job id should be set by provider'
6363
end
6464

6565
test 'should supply a provider_job_id when available for delayed jobs' do
66-
skip unless adapter_is?(:delayed_job, :sidekiq, :que)
66+
skip unless adapter_is?(:delayed_job, :sidekiq, :que, :queue_classic)
6767
delayed_test_job = TestJob.set(wait: 1.minute).perform_later @id
6868
assert delayed_test_job.provider_job_id, 'Provider job id should by set for delayed jobs by provider'
6969
end

0 commit comments

Comments
 (0)