diff --git a/README.md b/README.md index 9e3c56d..0880f2c 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,11 @@ Besides `base_controller_class`, you can also set the following for `MissionCont This library extends Active Job with a querying interface and the following setting: - `config.active_job.default_page_size`: the internal batch size that Active Job will use when sending queries to the underlying adapter and the batch size for the bulk operations defined above—defaults to `1000`. + +## Adapter Specifics + +- **Resque**: Queue pausing is supported only if you have `resque-pause` installed in your project + ## Advanced configuration When we built Mission Control Jobs, we did it with the idea of managing multiple apps' job backends from a single, centralized app that we used for monitoring, alerts and other tools that related to all our apps. Some of our apps run in more than one datacenter, and we run different Resque instances with different Redis configurations in each. Because of this, we added support for multiple apps and multiple adapters per app. Even when running Mission Control Job within the app it manages, and a single DC, as we migrated from Resque to Solid Queue, we needed to manage both adapters from Mission Control. diff --git a/lib/active_job/queue_adapters/resque_ext.rb b/lib/active_job/queue_adapters/resque_ext.rb index 2bb9ab2..042305b 100644 --- a/lib/active_job/queue_adapters/resque_ext.rb +++ b/lib/active_job/queue_adapters/resque_ext.rb @@ -81,6 +81,10 @@ def find_job(job_id, jobs_relation) resque_jobs_for(jobs_relation).find_job(job_id) end + def supports_queue_pausing? + defined?(ResquePauseHelper) + end + private attr_reader :redis diff --git a/test/active_job/queue_adapters/resque_test.rb b/test/active_job/queue_adapters/resque_test.rb index 01b10c6..4c7b792 100644 --- a/test/active_job/queue_adapters/resque_test.rb +++ b/test/active_job/queue_adapters/resque_test.rb @@ -3,7 +3,24 @@ class ActiveJob::QueueAdapters::ResqueTest < ActiveSupport::TestCase include ActiveJob::QueueAdapters::AdapterTesting + test "supports queue pausing when ResquePauseHelper is defined" do + assert ActiveJob::Base.queue_adapter.supports_queue_pausing? + end + + test "does not support queue pausing when ResquePauseHelper is not defined" do + emulating_resque_pause_gem_absence do + assert_not ActiveJob::Base.queue_adapter.supports_queue_pausing? + end + end + private + def emulating_resque_pause_gem_absence + helper_const = Object.send(:remove_const, :ResquePauseHelper) + yield + ensure + Object.const_set(:ResquePauseHelper, helper_const) + end + def queue_adapter :resque end