delayed_job_groups_plugin 0.13.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/delayed/job_groups/job_group.rb +2 -12
- data/lib/delayed/job_groups/plugin.rb +1 -7
- data/lib/delayed/job_groups/railtie.rb +0 -9
- data/lib/delayed/job_groups/version.rb +1 -1
- data/lib/delayed_job_groups_plugin.rb +0 -2
- data/spec/delayed/job_groups/job_group_spec.rb +1 -33
- data/spec/spec_helper.rb +3 -5
- metadata +2 -3
- data/lib/delayed/job_groups/errors.rb +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a151f3024b43407ef181bc42c113e97877160c37f48f1f68b793e533f001b88
|
4
|
+
data.tar.gz: d9f29810d2680e21956472ec485fe03f009765591cfadb9cb2fcaea17569c163
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a9b598b3f77a3256b6fbcca5ba5d1acd47c065c7d845fc19bf541ffe236779419f0439cf70ef82783c3185697305137acb8d0baf7eadc9f51d3796933d2e65d
|
7
|
+
data.tar.gz: b273960f4d058062e50c67a9144a6638f8574c97a72e5ec88a1388dc632778e3877c3e4f7218dc261789137e69382a0cd9d1600bc4800cb72b73f751c5dc93f8
|
data/CHANGELOG.md
CHANGED
@@ -62,18 +62,8 @@ module Delayed
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def cancel
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
Delayed::Job.enqueue(on_cancellation_job, on_cancellation_job_options || {}) if on_cancellation_job
|
69
|
-
destroy
|
70
|
-
end
|
71
|
-
rescue ActiveRecord::RecordNotFound
|
72
|
-
# The first failing job to attempt cancelling the job group will enqueue the
|
73
|
-
# on cancellation job and destroy the group. Any other concurrently failing job
|
74
|
-
# in the same group can therefore silently return if the job group has already
|
75
|
-
# been destroyed.
|
76
|
-
nil
|
65
|
+
Delayed::Job.enqueue(on_cancellation_job, on_cancellation_job_options || {}) if on_cancellation_job
|
66
|
+
destroy
|
77
67
|
end
|
78
68
|
|
79
69
|
def check_for_completion(skip_pending_jobs_check: false)
|
@@ -17,13 +17,7 @@ module Delayed
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
|
21
|
-
# job failure, a JobGroups on cancellation job must be enqueued in the after failure
|
22
|
-
# delayed job lifecycle hook. If both were to be performed in the same hook, the job's
|
23
|
-
# failure hook and the on cancellation job may run at the same time since hook execution
|
24
|
-
# order is never guaranteed. This is particular important if the on cancellation job
|
25
|
-
# depends on state set in the failure hook of an individual job.
|
26
|
-
lifecycle.after(:failure) do |_worker, job|
|
20
|
+
lifecycle.before(:failure) do |_worker, job|
|
27
21
|
# If a job in the job group fails, then cancel the whole job group.
|
28
22
|
# Need to check that the job group is present since another
|
29
23
|
# job may have concurrently cancelled it.
|
@@ -4,15 +4,6 @@ module Delayed
|
|
4
4
|
module JobGroups
|
5
5
|
class Railtie < ::Rails::Railtie
|
6
6
|
config.after_initialize do
|
7
|
-
|
8
|
-
# On cancellation checks are performed in the after failure delayed job lifecycle, however
|
9
|
-
# https://github.com/collectiveidea/delayed_job/blob/master/lib/delayed/worker.rb#L268 may
|
10
|
-
# delete jobs before the hook runs. This could cause a successful job in the same group to
|
11
|
-
# complete the group instead of the group being cancelled. Therefore, we must ensure that
|
12
|
-
# the Delayed::Worker.destroy_failed_jobs is set to false, guaranteeing that the group is
|
13
|
-
# never empty if failure occurs.
|
14
|
-
raise Delayed::JobGroups::IncompatibleWithDelayedJobError if Delayed::Worker.destroy_failed_jobs
|
15
|
-
|
16
7
|
Delayed::Backend::ActiveRecord::Job.include(Delayed::JobGroups::JobExtensions)
|
17
8
|
end
|
18
9
|
end
|
@@ -4,7 +4,6 @@ require 'active_support'
|
|
4
4
|
require 'active_record'
|
5
5
|
require 'delayed_job'
|
6
6
|
require 'delayed_job_active_record'
|
7
|
-
require 'delayed/job_groups/errors'
|
8
7
|
require 'delayed/job_groups/compatibility'
|
9
8
|
require 'delayed/job_groups/complete_stuck_job_groups_job'
|
10
9
|
require 'delayed/job_groups/job_extensions'
|
@@ -19,7 +18,6 @@ if defined?(Rails::Railtie)
|
|
19
18
|
else
|
20
19
|
# Do the same as in the railtie
|
21
20
|
Delayed::Backend::ActiveRecord::Job.include(Delayed::JobGroups::JobExtensions)
|
22
|
-
raise Delayed::JobGroups::IncompatibleWithDelayedJobError if Delayed::Worker.destroy_failed_jobs
|
23
21
|
end
|
24
22
|
|
25
23
|
Delayed::Worker.plugins << Delayed::JobGroups::Plugin
|
@@ -299,28 +299,11 @@ describe Delayed::JobGroups::JobGroup do
|
|
299
299
|
end
|
300
300
|
|
301
301
|
describe "#cancel" do
|
302
|
-
subject(:job_group) do
|
303
|
-
create(
|
304
|
-
:job_group,
|
305
|
-
on_completion_job: on_completion_job,
|
306
|
-
on_completion_job_options: on_completion_job_options,
|
307
|
-
on_cancellation_job: on_cancellation_job,
|
308
|
-
on_cancellation_job_options: on_cancellation_job_options,
|
309
|
-
blocked: blocked
|
310
|
-
)
|
311
|
-
end
|
312
|
-
|
313
302
|
let!(:queued_job) { Delayed::Job.create!(job_group_id: job_group.id) }
|
314
303
|
let!(:running_job) { Delayed::Job.create!(job_group_id: job_group.id, locked_at: Time.now, locked_by: 'test') }
|
315
|
-
let(:before_hook) {}
|
316
|
-
let(:on_cancellation_job) { 'dummy job' }
|
317
|
-
let(:on_cancellation_job_options) do
|
318
|
-
{ foo: 'bar' }
|
319
|
-
end
|
320
|
-
let(:cancel) { true }
|
321
304
|
|
322
305
|
before do
|
323
|
-
job_group.cancel
|
306
|
+
job_group.cancel
|
324
307
|
end
|
325
308
|
|
326
309
|
it "destroys the job group" do
|
@@ -334,21 +317,6 @@ describe Delayed::JobGroups::JobGroup do
|
|
334
317
|
it "does not destroy running jobs" do
|
335
318
|
expect(running_job).not_to have_been_destroyed
|
336
319
|
end
|
337
|
-
|
338
|
-
context "when already cancelled" do
|
339
|
-
let(:cancel) { false }
|
340
|
-
|
341
|
-
it "skips cancel block if already cancelled" do
|
342
|
-
other = Delayed::JobGroups::JobGroup.find(job_group.id)
|
343
|
-
job_group.cancel
|
344
|
-
|
345
|
-
other.cancel
|
346
|
-
other.cancel
|
347
|
-
|
348
|
-
expect(Delayed::Job)
|
349
|
-
.to have_received(:enqueue).with(on_cancellation_job, on_cancellation_job_options).once
|
350
|
-
end
|
351
|
-
end
|
352
320
|
end
|
353
321
|
|
354
322
|
describe "#failure_cancels_group?" do
|
data/spec/spec_helper.rb
CHANGED
@@ -13,11 +13,6 @@ end
|
|
13
13
|
|
14
14
|
require 'rspec/its'
|
15
15
|
require 'database_cleaner'
|
16
|
-
require 'delayed_job'
|
17
|
-
|
18
|
-
Delayed::Worker.read_ahead = 1
|
19
|
-
Delayed::Worker.destroy_failed_jobs = false
|
20
|
-
|
21
16
|
require 'delayed_job_groups_plugin'
|
22
17
|
require 'factory_bot'
|
23
18
|
require 'yaml'
|
@@ -28,6 +23,9 @@ Dir["#{spec_dir}/support/**/*.rb"].sort.each { |f| require f }
|
|
28
23
|
|
29
24
|
FileUtils.makedirs('log')
|
30
25
|
|
26
|
+
Delayed::Worker.read_ahead = 1
|
27
|
+
Delayed::Worker.destroy_failed_jobs = false
|
28
|
+
|
31
29
|
Delayed::Worker.logger = Logger.new('log/test.log')
|
32
30
|
Delayed::Worker.logger.level = Logger::DEBUG
|
33
31
|
ActiveRecord::Base.logger = Delayed::Worker.logger
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: delayed_job_groups_plugin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joel Turkel
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2025-09-
|
12
|
+
date: 2025-09-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -269,7 +269,6 @@ files:
|
|
269
269
|
- gemfiles/rails_8.0.gemfile
|
270
270
|
- lib/delayed/job_groups/compatibility.rb
|
271
271
|
- lib/delayed/job_groups/complete_stuck_job_groups_job.rb
|
272
|
-
- lib/delayed/job_groups/errors.rb
|
273
272
|
- lib/delayed/job_groups/job_extensions.rb
|
274
273
|
- lib/delayed/job_groups/job_group.rb
|
275
274
|
- lib/delayed/job_groups/plugin.rb
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Delayed
|
4
|
-
module JobGroups
|
5
|
-
ConfigurationError = Class.new(StandardError)
|
6
|
-
|
7
|
-
class IncompatibleWithDelayedJobError < ConfigurationError
|
8
|
-
DEFAULT_MESSAGE = 'DelayedJobGroupsPlugin is incompatible with Delayed::Job ' \
|
9
|
-
'when `destroy_failed_jobs` is set to `true`'
|
10
|
-
|
11
|
-
def initialize(msg = DEFAULT_MESSAGE)
|
12
|
-
super(msg)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|