Skip to content

Commit

Permalink
Include concurrency controls extension directly in ActiveJob
Browse files Browse the repository at this point in the history
  • Loading branch information
rosa committed Nov 16, 2023
1 parent cfee579 commit 6b11253
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 8 deletions.
6 changes: 6 additions & 0 deletions lib/solid_queue/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,11 @@ class Engine < ::Rails::Engine
self.logger = app.logger
end
end

initializer "solid_queue.active_job.extensions" do
ActiveSupport.on_load :active_job do
include ActiveJob::ConcurrencyControls
end
end
end
end
2 changes: 0 additions & 2 deletions test/dummy/app/jobs/sequential_update_result_job.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
class SequentialUpdateResultJob < UpdateResultJob
include ActiveJob::ConcurrencyControls

restrict_concurrency_with limit: 1, key: ->(job_result, **) { job_result }
end
2 changes: 0 additions & 2 deletions test/dummy/app/jobs/throttled_update_result_job.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
class ThrottledUpdateResultJob < UpdateResultJob
include ActiveJob::ConcurrencyControls

restrict_concurrency_with limit: 3, key: ->(job_result, **) { job_result }
end
2 changes: 0 additions & 2 deletions test/dummy/app/jobs/update_result_job.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
class UpdateResultJob < ApplicationJob
include ActiveJob::ConcurrencyControls

def perform(job_result, name:, pause: nil, exception: nil)
job_result.status += "s#{name}"

Expand Down
2 changes: 0 additions & 2 deletions test/models/solid_queue/job_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

class SolidQueue::JobTest < ActiveSupport::TestCase
class NonOverlappingJob < ApplicationJob
include ActiveJob::ConcurrencyControls

restrict_concurrency_with limit: 1, key: ->(job_result, **) { job_result }

def perform(job_result)
Expand Down

0 comments on commit 6b11253

Please sign in to comment.