Skip to content

Commit

Permalink
implement provider_job_id for queue_classic.
Browse files Browse the repository at this point in the history
The latest, currently unreleased, version of queue_classic is required
for this to work. See
QueueClassic/queue_classic#262 for more details.
  • Loading branch information
senny committed Aug 13, 2015
1 parent 0650d08 commit 68e3279
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ group :job do
gem 'sidekiq', require: false
gem 'sucker_punch', require: false
gem 'delayed_job', require: false
gem 'queue_classic', require: false, platforms: :ruby
gem 'queue_classic', github: "QueueClassic/queue_classic", require: false, platforms: :ruby
gem 'sneakers', require: false
gem 'que', require: false
gem 'backburner', require: false
Expand Down
11 changes: 8 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
GIT
remote: git://github.com/QueueClassic/queue_classic.git
revision: d144db29f1436e9e8b3c7a1a1ecd4442316a9ecd
specs:
queue_classic (3.2.0.alpha)
pg (>= 0.17, < 0.19)

GIT
remote: git://github.com/bkeepers/qu.git
revision: d098e2657c92e89a6413bebd9c033930759c061f
Expand Down Expand Up @@ -173,8 +180,6 @@ GEM
pg (0.18.2)
psych (2.0.13)
que (0.10.0)
queue_classic (3.1.0)
pg (>= 0.17, < 0.19)
racc (1.4.12)
rack (1.6.4)
rack-cache (1.2)
Expand Down Expand Up @@ -289,7 +294,7 @@ DEPENDENCIES
qu-rails!
qu-redis
que
queue_classic
queue_classic!
racc (>= 1.4.6)
rack-cache (~> 1.2)
rails!
Expand Down
7 changes: 6 additions & 1 deletion activejob/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
* Implement `provider_job_id` for `queue_classic` adapter. This requires the
latest, currently unreleased, version of queue_classic.

*Yves Senn*

* `assert_enqueued_with` and `assert_performed_with` now returns the matched
job instance for further assertions.

*Jean Boussier*

* Include I18n.locale into job serialization/deserialization and use it around
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ module QueueAdapters
# Rails.application.config.active_job.queue_adapter = :queue_classic
class QueueClassicAdapter
def enqueue(job) #:nodoc:
build_queue(job.queue_name).enqueue("#{JobWrapper.name}.perform", job.serialize)
qc_job = build_queue(job.queue_name).enqueue("#{JobWrapper.name}.perform", job.serialize)
job.provider_job_id = qc_job["id"] if qc_job.is_a?(Hash)
qc_job
end

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

# Builds a <tt>QC::Queue</tt> object to schedule jobs on.
Expand Down
4 changes: 2 additions & 2 deletions activejob/test/integration/queuing_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ class QueuingTest < ActiveSupport::TestCase
end

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

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

0 comments on commit 68e3279

Please sign in to comment.