Skip to content

Commit 3f87333

Browse files
committed
Include concurrency controls extension directly in ActiveJob
1 parent 362b2f9 commit 3f87333

File tree

5 files changed

+6
-8
lines changed

5 files changed

+6
-8
lines changed

lib/solid_queue/engine.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,11 @@ class Engine < ::Rails::Engine
2727
self.logger = app.logger
2828
end
2929
end
30+
31+
initializer "solid_queue.active_job.extensions" do
32+
ActiveSupport.on_load :active_job do
33+
include ActiveJob::ConcurrencyControls
34+
end
35+
end
3036
end
3137
end
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
class SequentialUpdateResultJob < UpdateResultJob
2-
include ActiveJob::ConcurrencyControls
3-
42
restrict_concurrency_with limit: 1, key: ->(job_result, **) { job_result }
53
end
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
class ThrottledUpdateResultJob < UpdateResultJob
2-
include ActiveJob::ConcurrencyControls
3-
42
restrict_concurrency_with limit: 3, key: ->(job_result, **) { job_result }
53
end

test/dummy/app/jobs/update_result_job.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
class UpdateResultJob < ApplicationJob
2-
include ActiveJob::ConcurrencyControls
3-
42
def perform(job_result, name:, pause: nil, exception: nil)
53
job_result.status += "s#{name}"
64

test/models/solid_queue/job_test.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
class SolidQueue::JobTest < ActiveSupport::TestCase
44
class NonOverlappingJob < ApplicationJob
5-
include ActiveJob::ConcurrencyControls
6-
75
restrict_concurrency_with limit: 1, key: ->(job_result, **) { job_result }
86

97
def perform(job_result)

0 commit comments

Comments
 (0)