mirror of https://github.com/rails/rails
implement `provider_job_id` for `queue_classic`.
The latest, currently unreleased, version of queue_classic is required for this to work. See https://github.com/QueueClassic/queue_classic/pull/262 for more details.
This commit is contained in:
parent
0650d08488
commit
68e3279163
2
Gemfile
2
Gemfile
|
@ -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
|
||||
|
|
11
Gemfile.lock
11
Gemfile.lock
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -289,7 +294,7 @@ DEPENDENCIES
|
|||
qu-rails!
|
||||
qu-redis
|
||||
que
|
||||
queue_classic
|
||||
queue_classic!
|
||||
racc (>= 1.4.6)
|
||||
rack-cache (~> 1.2)
|
||||
rails!
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -18,7 +18,9 @@ module ActiveJob
|
|||
# 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:
|
||||
|
@ -28,7 +30,9 @@ module ActiveJob
|
|||
'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.
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue