delayed_job_groups_plugin 0.6.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +17 -11
- data/.github/CODEOWNERS +1 -0
- data/.rubocop.yml +2 -2
- data/Appraisals +9 -10
- data/CHANGELOG.md +17 -1
- data/delayed_job_groups.gemspec +13 -6
- data/gemfiles/rails_6.0.gemfile +2 -2
- data/gemfiles/rails_6.1.gemfile +2 -2
- data/gemfiles/{rails_5.2.gemfile → rails_7.0.gemfile} +2 -3
- data/lib/delayed/job_groups/compatibility.rb +0 -4
- data/lib/delayed/job_groups/job_extensions.rb +1 -5
- data/lib/delayed/job_groups/job_group.rb +3 -6
- data/lib/delayed/job_groups/plugin.rb +1 -3
- data/lib/delayed/job_groups/railtie.rb +11 -0
- data/lib/delayed/job_groups/version.rb +1 -1
- data/lib/delayed/job_groups/yaml_loader.rb +2 -0
- data/lib/delayed_job_groups_plugin.rb +7 -1
- data/spec/delayed/job_groups/job_extensions_spec.rb +9 -0
- data/spec/delayed/job_groups/job_group_spec.rb +4 -0
- data/spec/delayed/job_groups/plugin_spec.rb +44 -75
- data/spec/delayed/job_groups/yaml_loader_spec.rb +4 -6
- data/spec/support/test_jobs.rb +33 -0
- metadata +27 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc7b851a75a0814848eac3a150ddd9517411c78e8d4c5f02230bf8ed00e6dded
|
4
|
+
data.tar.gz: 87d0123a70117592b305eeb1096e9c9bcf3ba590638bd522e7b453f3439db244
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: caa34cca5bcc4558a85ec8147132a4596fcbe95b45b755468902a81ac89a49cc16405dd3107c6e60a6455a39d3c5b3c609a7f142e41f44220577ae0da5ace362
|
7
|
+
data.tar.gz: 05d1861bf1316638dc689b59dd56a5e7ebffa6a4dfb5e2ca3a9e5fde849f4a099ce2c9927a927630a4201881f50872e4462c7e32ad221f2f006af0cd1f836375
|
data/.circleci/config.yml
CHANGED
@@ -2,14 +2,14 @@ version: 2.1
|
|
2
2
|
jobs:
|
3
3
|
lint:
|
4
4
|
docker:
|
5
|
-
- image: salsify/ruby_ci:2.
|
5
|
+
- image: salsify/ruby_ci:2.7.6
|
6
6
|
working_directory: ~/delayed_job_groups
|
7
7
|
steps:
|
8
8
|
- checkout
|
9
9
|
- restore_cache:
|
10
10
|
keys:
|
11
|
-
- v1-gems-ruby-2.
|
12
|
-
- v1-gems-ruby-2.
|
11
|
+
- v1-gems-ruby-2.7.6-{{ checksum "delayed_job_groups.gemspec" }}-{{ checksum "Gemfile" }}
|
12
|
+
- v1-gems-ruby-2.7.6-
|
13
13
|
- run:
|
14
14
|
name: Install Gems
|
15
15
|
command: |
|
@@ -18,7 +18,7 @@ jobs:
|
|
18
18
|
bundle clean
|
19
19
|
fi
|
20
20
|
- save_cache:
|
21
|
-
key: v1-gems-ruby-2.
|
21
|
+
key: v1-gems-ruby-2.7.6-{{ checksum "delayed_job_groups.gemspec" }}-{{ checksum "Gemfile" }}
|
22
22
|
paths:
|
23
23
|
- "vendor/bundle"
|
24
24
|
- "gemfiles/vendor/bundle"
|
@@ -29,8 +29,10 @@ jobs:
|
|
29
29
|
parameters:
|
30
30
|
gemfile:
|
31
31
|
type: string
|
32
|
+
ruby_version:
|
33
|
+
type: string
|
32
34
|
docker:
|
33
|
-
- image: salsify/ruby_ci
|
35
|
+
- image: salsify/ruby_ci:<< parameters.ruby_version >>
|
34
36
|
environment:
|
35
37
|
CIRCLE_TEST_REPORTS: "test-results"
|
36
38
|
BUNDLE_GEMFILE: << parameters.gemfile >>
|
@@ -39,8 +41,8 @@ jobs:
|
|
39
41
|
- checkout
|
40
42
|
- restore_cache:
|
41
43
|
keys:
|
42
|
-
- v1-gems-ruby
|
43
|
-
- v1-gems-ruby
|
44
|
+
- v1-gems-ruby-<< parameters.ruby_version >>-{{ checksum "delayed_job_groups.gemspec" }}-{{ checksum "<< parameters.gemfile >>" }}
|
45
|
+
- v1-gems-ruby-<< parameters.ruby_version >>-
|
44
46
|
- run:
|
45
47
|
name: Install Gems
|
46
48
|
command: |
|
@@ -49,7 +51,7 @@ jobs:
|
|
49
51
|
bundle clean
|
50
52
|
fi
|
51
53
|
- save_cache:
|
52
|
-
key: v1-gems-ruby
|
54
|
+
key: v1-gems-ruby-<< parameters.ruby_version >>-{{ checksum "delayed_job_groups.gemspec" }}-{{ checksum "<< parameters.gemfile >>" }}
|
53
55
|
paths:
|
54
56
|
- "vendor/bundle"
|
55
57
|
- "gemfiles/vendor/bundle"
|
@@ -67,6 +69,10 @@ workflows:
|
|
67
69
|
matrix:
|
68
70
|
parameters:
|
69
71
|
gemfile:
|
70
|
-
|
71
|
-
|
72
|
-
|
72
|
+
- "gemfiles/rails_6.0.gemfile"
|
73
|
+
- "gemfiles/rails_6.1.gemfile"
|
74
|
+
- "gemfiles/rails_7.0.gemfile"
|
75
|
+
ruby_version:
|
76
|
+
- "2.7.6"
|
77
|
+
- "3.0.4"
|
78
|
+
- "3.1.2"
|
data/.github/CODEOWNERS
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
* @jturkel @will89
|
data/.rubocop.yml
CHANGED
data/Appraisals
CHANGED
@@ -1,17 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
appraise 'rails-5.2' do
|
4
|
-
gem 'sqlite3', '~> 1.3.6'
|
5
|
-
gem 'activerecord', '5.2.1'
|
6
|
-
gem 'activesupport', '5.2.1'
|
7
|
-
end
|
8
|
-
|
9
3
|
appraise 'rails-6.0' do
|
10
|
-
gem 'activerecord', '6.0.
|
11
|
-
gem 'activesupport', '6.0.
|
4
|
+
gem 'activerecord', '~> 6.0.4'
|
5
|
+
gem 'activesupport', '~> 6.0.4'
|
12
6
|
end
|
13
7
|
|
14
8
|
appraise 'rails-6.1' do
|
15
|
-
gem 'activerecord', '6.1.
|
16
|
-
gem 'activesupport', '6.1.
|
9
|
+
gem 'activerecord', '~> 6.1.5'
|
10
|
+
gem 'activesupport', '~> 6.1.5'
|
11
|
+
end
|
12
|
+
|
13
|
+
appraise 'rails-7.0' do
|
14
|
+
gem 'activerecord', '~> 7.0.2'
|
15
|
+
gem 'activesupport', '~> 7.0.2'
|
17
16
|
end
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,23 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
### 0.8.0
|
4
|
+
- Drop support for ruby < 2.7
|
5
|
+
- Add support for ruby 3.1
|
6
|
+
- Drop Rails 5.2
|
7
|
+
- Add Rails 7.0
|
8
|
+
|
9
|
+
### 0.7.0
|
10
|
+
* Add support for ruby 3
|
11
|
+
* Drop support for ruby < 2.6
|
12
|
+
|
13
|
+
### 0.6.2
|
14
|
+
* Defer including extension until delayed_job_active_record is loaded
|
15
|
+
|
16
|
+
### 0.6.1
|
17
|
+
* Fix job_group_id `belongs_to` behavior when `config.active_record.belongs_to_required_by_default` is enabled.
|
18
|
+
|
3
19
|
### 0.6.0
|
4
|
-
*
|
20
|
+
* Add support for Rails 6.1.
|
5
21
|
|
6
22
|
### 0.5.0
|
7
23
|
* Drop support for Ruby 2.3 and 2.4.
|
data/delayed_job_groups.gemspec
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
|
2
1
|
# frozen_string_literal: true
|
3
2
|
|
4
|
-
lib = File.expand_path('
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
5
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
6
5
|
require 'delayed/job_groups/version'
|
7
6
|
|
@@ -15,19 +14,27 @@ Gem::Specification.new do |spec|
|
|
15
14
|
spec.homepage = 'https://github.com/salsify/delayed_job_groups_plugin'
|
16
15
|
spec.license = 'MIT'
|
17
16
|
|
17
|
+
if spec.respond_to?(:metadata)
|
18
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
19
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
20
|
+
else
|
21
|
+
raise 'RubyGems 2.0 or newer is required to set allowed_push_host.'
|
22
|
+
end
|
23
|
+
|
18
24
|
spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
19
25
|
spec.test_files = Dir.glob('spec/**/*')
|
20
26
|
spec.require_paths = ['lib']
|
21
27
|
|
22
|
-
spec.required_ruby_version = '>= 2.
|
28
|
+
spec.required_ruby_version = '>= 2.7'
|
23
29
|
|
24
30
|
spec.add_dependency 'delayed_job', '>= 4.1'
|
25
31
|
spec.add_dependency 'delayed_job_active_record', '>= 4.1'
|
26
32
|
|
27
|
-
spec.post_install_message = 'See https://github.com/salsify/delayed_job_groups_plugin#installation
|
33
|
+
spec.post_install_message = 'See https://github.com/salsify/delayed_job_groups_plugin#installation '\
|
34
|
+
'for upgrade/installation notes.'
|
28
35
|
|
29
36
|
spec.add_development_dependency 'appraisal'
|
30
|
-
spec.add_dependency 'activerecord', '>= 5.2', '< 7'
|
37
|
+
spec.add_dependency 'activerecord', '>= 5.2', '< 7.1'
|
31
38
|
spec.add_development_dependency 'coveralls_reborn', '>= 0.18.0'
|
32
39
|
spec.add_development_dependency 'database_cleaner', '>= 1.2'
|
33
40
|
spec.add_development_dependency 'mime-types'
|
@@ -35,7 +42,7 @@ Gem::Specification.new do |spec|
|
|
35
42
|
spec.add_development_dependency 'rspec', '~> 3'
|
36
43
|
spec.add_development_dependency 'rspec-its'
|
37
44
|
spec.add_development_dependency 'rspec_junit_formatter'
|
38
|
-
spec.add_development_dependency 'salsify_rubocop', '0.
|
45
|
+
spec.add_development_dependency 'salsify_rubocop', '~> 1.0.1'
|
39
46
|
spec.add_development_dependency 'simplecov'
|
40
47
|
spec.add_development_dependency 'sqlite3'
|
41
48
|
spec.add_development_dependency 'timecop'
|
data/gemfiles/rails_6.0.gemfile
CHANGED
data/gemfiles/rails_6.1.gemfile
CHANGED
@@ -11,11 +11,7 @@ module Delayed
|
|
11
11
|
end
|
12
12
|
|
13
13
|
included do
|
14
|
-
|
15
|
-
attr_accessible :job_group_id, :blocked
|
16
|
-
end
|
17
|
-
|
18
|
-
belongs_to :job_group, class_name: 'Delayed::JobGroups::JobGroup'
|
14
|
+
belongs_to :job_group, class_name: 'Delayed::JobGroups::JobGroup', required: false
|
19
15
|
|
20
16
|
class << self
|
21
17
|
prepend ReadyToRunExtension
|
@@ -8,11 +8,6 @@ module Delayed
|
|
8
8
|
|
9
9
|
self.table_name = "#{ActiveRecord::Base.table_name_prefix}delayed_job_groups"
|
10
10
|
|
11
|
-
if Delayed::JobGroups::Compatibility.mass_assignment_security_enabled?
|
12
|
-
attr_accessible :on_completion_job, :on_completion_job_options, :blocked, :on_cancellation_job,
|
13
|
-
:on_cancellation_job_options, :failure_cancels_group
|
14
|
-
end
|
15
|
-
|
16
11
|
serialize :on_completion_job, Delayed::JobGroups::YamlLoader
|
17
12
|
serialize :on_completion_job_options, Hash
|
18
13
|
serialize :on_cancellation_job, Delayed::JobGroups::YamlLoader
|
@@ -30,6 +25,7 @@ module Delayed
|
|
30
25
|
def mark_queueing_complete
|
31
26
|
with_lock do
|
32
27
|
raise 'JobGroup has already completed queueing' if queueing_complete?
|
28
|
+
|
33
29
|
update_column(:queueing_complete, true)
|
34
30
|
complete if ready_for_completion?
|
35
31
|
end
|
@@ -66,13 +62,14 @@ module Delayed
|
|
66
62
|
# zero will queue the job group's completion job and destroy the job group so
|
67
63
|
# other jobs need to handle the job group having been destroyed already.
|
68
64
|
job_group = where(id: job_group_id).lock(true).first
|
69
|
-
job_group.send(:complete) if job_group
|
65
|
+
job_group.send(:complete) if job_group&.send(:ready_for_completion?)
|
70
66
|
end
|
71
67
|
end
|
72
68
|
|
73
69
|
def self.has_pending_jobs?(job_group_ids) # rubocop:disable Naming/PredicateName
|
74
70
|
job_group_ids = Array(job_group_ids)
|
75
71
|
return false if job_group_ids.empty?
|
72
|
+
|
76
73
|
Delayed::Job.where(job_group_id: job_group_ids, failed_at: nil).exists?
|
77
74
|
end
|
78
75
|
|
@@ -21,9 +21,7 @@ module Delayed
|
|
21
21
|
# If a job in the job group fails, then cancel the whole job group.
|
22
22
|
# Need to check that the job group is present since another
|
23
23
|
# job may have concurrently cancelled it.
|
24
|
-
if job.in_job_group? && job.job_group
|
25
|
-
job.job_group.cancel
|
26
|
-
end
|
24
|
+
job.job_group.cancel if job.in_job_group? && job.job_group&.failure_cancels_group?
|
27
25
|
end
|
28
26
|
|
29
27
|
lifecycle.after(:perform) do |_worker, job|
|
@@ -11,6 +11,12 @@ require 'delayed/job_groups/plugin'
|
|
11
11
|
require 'delayed/job_groups/yaml_loader'
|
12
12
|
require 'delayed/job_groups/version'
|
13
13
|
|
14
|
-
|
14
|
+
if defined?(Rails::Railtie)
|
15
|
+
# Postpone initialization to railtie for correct order
|
16
|
+
require 'delayed/job_groups/railtie'
|
17
|
+
else
|
18
|
+
# Do the same as in the railtie
|
19
|
+
Delayed::Backend::ActiveRecord::Job.include(Delayed::JobGroups::JobExtensions)
|
20
|
+
end
|
15
21
|
|
16
22
|
Delayed::Worker.plugins << Delayed::JobGroups::Plugin
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe "delayed job extensions" do
|
4
|
+
it "provides an optional job_group_id" do
|
5
|
+
job_group = Delayed::JobGroups::JobGroup.create!
|
6
|
+
expect(Delayed::Job.new(job_group_id: job_group.id)).to be_valid
|
7
|
+
expect(Delayed::Job.new).to be_valid
|
8
|
+
end
|
9
|
+
end
|
@@ -50,6 +50,7 @@ describe Delayed::JobGroups::JobGroup do
|
|
50
50
|
before { job_group.mark_queueing_complete }
|
51
51
|
|
52
52
|
it { is_expected.to be_queueing_complete }
|
53
|
+
|
53
54
|
it_behaves_like "the job group was completed"
|
54
55
|
end
|
55
56
|
|
@@ -59,6 +60,7 @@ describe Delayed::JobGroups::JobGroup do
|
|
59
60
|
before { job_group.mark_queueing_complete }
|
60
61
|
|
61
62
|
it { is_expected.to be_queueing_complete }
|
63
|
+
|
62
64
|
it_behaves_like "the job group was not completed"
|
63
65
|
end
|
64
66
|
|
@@ -69,6 +71,7 @@ describe Delayed::JobGroups::JobGroup do
|
|
69
71
|
end
|
70
72
|
|
71
73
|
it { is_expected.to be_queueing_complete }
|
74
|
+
|
72
75
|
it_behaves_like "the job group was not completed"
|
73
76
|
end
|
74
77
|
end
|
@@ -199,6 +202,7 @@ describe Delayed::JobGroups::JobGroup do
|
|
199
202
|
end
|
200
203
|
|
201
204
|
its(:blocked?) { is_expected.to be(false) }
|
205
|
+
|
202
206
|
it_behaves_like "the job group was completed"
|
203
207
|
end
|
204
208
|
end
|
@@ -5,56 +5,56 @@ describe Delayed::JobGroups::Plugin do
|
|
5
5
|
@old_max_attempts = Delayed::Worker.max_attempts
|
6
6
|
Delayed::Worker.max_attempts = 2
|
7
7
|
|
8
|
-
CompletionJob.invoked = false
|
9
|
-
CancellationJob.invoked = false
|
8
|
+
TestJobs::CompletionJob.invoked = false
|
9
|
+
TestJobs::CancellationJob.invoked = false
|
10
10
|
end
|
11
11
|
|
12
12
|
after do
|
13
13
|
Delayed::Worker.max_attempts = @old_max_attempts
|
14
14
|
end
|
15
15
|
|
16
|
-
let!(:job_group) { Delayed::JobGroups::JobGroup.create!(on_completion_job: CompletionJob.new) }
|
16
|
+
let!(:job_group) { Delayed::JobGroups::JobGroup.create!(on_completion_job: TestJobs::CompletionJob.new) }
|
17
17
|
|
18
18
|
it "runs the completion job after completing other jobs" do
|
19
|
-
job_group.enqueue(NoOpJob.new)
|
20
|
-
job_group.enqueue(NoOpJob.new)
|
19
|
+
job_group.enqueue(TestJobs::NoOpJob.new)
|
20
|
+
job_group.enqueue(TestJobs::NoOpJob.new)
|
21
21
|
job_group.mark_queueing_complete
|
22
22
|
expect(job_group_count).to eq 1
|
23
23
|
expect(queued_job_count).to eq 2
|
24
24
|
|
25
25
|
# Run our first job
|
26
26
|
Delayed::Worker.new.work_off(1)
|
27
|
-
expect(CompletionJob.invoked).to be(false)
|
27
|
+
expect(TestJobs::CompletionJob.invoked).to be(false)
|
28
28
|
expect(job_group_count).to eq 1
|
29
29
|
expect(queued_job_count).to eq 1
|
30
30
|
|
31
31
|
# Run our second job which should enqueue the completion job
|
32
32
|
Delayed::Worker.new.work_off(1)
|
33
|
-
expect(CompletionJob.invoked).to be(false)
|
33
|
+
expect(TestJobs::CompletionJob.invoked).to be(false)
|
34
34
|
expect(job_group_count).to eq 0
|
35
35
|
expect(queued_job_count).to eq 1
|
36
36
|
|
37
37
|
# Now we should run the completion job
|
38
38
|
Delayed::Worker.new.work_off(1)
|
39
|
-
expect(CompletionJob.invoked).to be(true)
|
39
|
+
expect(TestJobs::CompletionJob.invoked).to be(true)
|
40
40
|
expect(queued_job_count).to eq 0
|
41
41
|
end
|
42
42
|
|
43
43
|
it "only runs the completion job after queueing is completed" do
|
44
|
-
job_group.enqueue(NoOpJob.new)
|
45
|
-
job_group.enqueue(NoOpJob.new)
|
44
|
+
job_group.enqueue(TestJobs::NoOpJob.new)
|
45
|
+
job_group.enqueue(TestJobs::NoOpJob.new)
|
46
46
|
expect(job_group_count).to eq 1
|
47
47
|
expect(queued_job_count).to eq 2
|
48
48
|
|
49
49
|
# Run our first job
|
50
50
|
Delayed::Worker.new.work_off(1)
|
51
|
-
expect(CompletionJob.invoked).to be(false)
|
51
|
+
expect(TestJobs::CompletionJob.invoked).to be(false)
|
52
52
|
expect(job_group_count).to eq 1
|
53
53
|
expect(queued_job_count).to eq 1
|
54
54
|
|
55
55
|
# Run our second job
|
56
56
|
Delayed::Worker.new.work_off(1)
|
57
|
-
expect(CompletionJob.invoked).to be(false)
|
57
|
+
expect(TestJobs::CompletionJob.invoked).to be(false)
|
58
58
|
expect(job_group_count).to eq 1
|
59
59
|
expect(queued_job_count).to eq 0
|
60
60
|
|
@@ -65,7 +65,7 @@ describe Delayed::JobGroups::Plugin do
|
|
65
65
|
|
66
66
|
# Now we should run the completion job
|
67
67
|
Delayed::Worker.new.work_off(1)
|
68
|
-
expect(CompletionJob.invoked).to be(true)
|
68
|
+
expect(TestJobs::CompletionJob.invoked).to be(true)
|
69
69
|
expect(queued_job_count).to eq 0
|
70
70
|
end
|
71
71
|
|
@@ -75,8 +75,8 @@ describe Delayed::JobGroups::Plugin do
|
|
75
75
|
it "cancels the group" do
|
76
76
|
Delayed::Worker.max_attempts = 1
|
77
77
|
|
78
|
-
job_group.enqueue(FailingJob.new)
|
79
|
-
job_group.enqueue(NoOpJob.new)
|
78
|
+
job_group.enqueue(TestJobs::FailingJob.new)
|
79
|
+
job_group.enqueue(TestJobs::NoOpJob.new)
|
80
80
|
job_group.mark_queueing_complete
|
81
81
|
expect(queued_job_count).to eq 2
|
82
82
|
expect(job_group_count).to eq 1
|
@@ -84,7 +84,7 @@ describe Delayed::JobGroups::Plugin do
|
|
84
84
|
# Run the job which should fail and cancel the JobGroup
|
85
85
|
Delayed::Worker.new.work_off(1)
|
86
86
|
# Completion job is not invoked
|
87
|
-
expect(CompletionJob.invoked).to be(false)
|
87
|
+
expect(TestJobs::CompletionJob.invoked).to be(false)
|
88
88
|
expect(failed_job_count).to eq 1
|
89
89
|
expect(queued_job_count).to eq 0
|
90
90
|
expect(job_group_count).to eq 0
|
@@ -98,15 +98,15 @@ describe Delayed::JobGroups::Plugin do
|
|
98
98
|
it "does not cancel the group" do
|
99
99
|
Delayed::Worker.max_attempts = 1
|
100
100
|
|
101
|
-
job_group.enqueue(FailingJob.new)
|
102
|
-
job_group.enqueue(NoOpJob.new)
|
101
|
+
job_group.enqueue(TestJobs::FailingJob.new)
|
102
|
+
job_group.enqueue(TestJobs::NoOpJob.new)
|
103
103
|
job_group.mark_queueing_complete
|
104
104
|
expect(queued_job_count).to eq 2
|
105
105
|
expect(job_group_count).to eq 1
|
106
106
|
|
107
107
|
# Run the job which should fail don't cancel the JobGroup
|
108
108
|
Delayed::Worker.new.work_off(1)
|
109
|
-
expect(CancellationJob.invoked).to be(false)
|
109
|
+
expect(TestJobs::CancellationJob.invoked).to be(false)
|
110
110
|
expect(failed_job_count).to eq 1
|
111
111
|
expect(queued_job_count).to eq 1
|
112
112
|
expect(job_group_count).to eq 1
|
@@ -120,7 +120,7 @@ describe Delayed::JobGroups::Plugin do
|
|
120
120
|
# Run the completion job
|
121
121
|
Delayed::Worker.new.work_off(1)
|
122
122
|
# Completion job is invoked
|
123
|
-
expect(CompletionJob.invoked).to be(true)
|
123
|
+
expect(TestJobs::CompletionJob.invoked).to be(true)
|
124
124
|
expect(failed_job_count).to eq 1
|
125
125
|
expect(queued_job_count).to eq 0
|
126
126
|
expect(job_group_count).to eq 0
|
@@ -129,8 +129,8 @@ describe Delayed::JobGroups::Plugin do
|
|
129
129
|
it "runs completion job if last job failed" do
|
130
130
|
Delayed::Worker.max_attempts = 2
|
131
131
|
|
132
|
-
job_group.enqueue(NoOpJob.new)
|
133
|
-
job_group.enqueue(FailingJob.new)
|
132
|
+
job_group.enqueue(TestJobs::NoOpJob.new)
|
133
|
+
job_group.enqueue(TestJobs::FailingJob.new)
|
134
134
|
job_group.mark_queueing_complete
|
135
135
|
expect(queued_job_count).to eq 2
|
136
136
|
expect(job_group_count).to eq 1
|
@@ -144,7 +144,7 @@ describe Delayed::JobGroups::Plugin do
|
|
144
144
|
# Run the job which should error
|
145
145
|
Delayed::Worker.new.work_off(1)
|
146
146
|
# Completion job is not invoked
|
147
|
-
expect(CompletionJob.invoked).to be(false)
|
147
|
+
expect(TestJobs::CompletionJob.invoked).to be(false)
|
148
148
|
expect(failed_job_count).to eq 0
|
149
149
|
expect(queued_job_count).to eq 1
|
150
150
|
expect(job_group_count).to eq 1
|
@@ -159,7 +159,7 @@ describe Delayed::JobGroups::Plugin do
|
|
159
159
|
# Run the completion job
|
160
160
|
Delayed::Worker.new.work_off(1)
|
161
161
|
# Completion job is invoked
|
162
|
-
expect(CompletionJob.invoked).to be(true)
|
162
|
+
expect(TestJobs::CompletionJob.invoked).to be(true)
|
163
163
|
expect(failed_job_count).to eq 1
|
164
164
|
expect(queued_job_count).to eq 0
|
165
165
|
expect(job_group_count).to eq 0
|
@@ -169,7 +169,7 @@ describe Delayed::JobGroups::Plugin do
|
|
169
169
|
|
170
170
|
it "doesn't retry failed jobs if the job group has been canceled" do
|
171
171
|
job_group.cancel
|
172
|
-
Delayed::Job.enqueue(FailingJob.new, job_group_id: job_group.id)
|
172
|
+
Delayed::Job.enqueue(TestJobs::FailingJob.new, job_group_id: job_group.id)
|
173
173
|
expect(queued_job_count).to eq 1
|
174
174
|
|
175
175
|
# Run the job which should fail and should not queue a retry
|
@@ -182,8 +182,8 @@ describe Delayed::JobGroups::Plugin do
|
|
182
182
|
job_group.blocked = true
|
183
183
|
job_group.save!
|
184
184
|
|
185
|
-
job_group.enqueue(NoOpJob.new)
|
186
|
-
job_group.enqueue(NoOpJob.new)
|
185
|
+
job_group.enqueue(TestJobs::NoOpJob.new)
|
186
|
+
job_group.enqueue(TestJobs::NoOpJob.new)
|
187
187
|
job_group.mark_queueing_complete
|
188
188
|
expect(Delayed::Job.count).to eq 2
|
189
189
|
|
@@ -197,41 +197,41 @@ describe Delayed::JobGroups::Plugin do
|
|
197
197
|
|
198
198
|
# Run our first job
|
199
199
|
Delayed::Worker.new.work_off(1)
|
200
|
-
expect(CompletionJob.invoked).to be(false)
|
200
|
+
expect(TestJobs::CompletionJob.invoked).to be(false)
|
201
201
|
expect(job_group_count).to eq 1
|
202
202
|
expect(Delayed::Job.count).to eq 1
|
203
203
|
|
204
204
|
# Run our second job which should enqueue the completion job
|
205
205
|
Delayed::Worker.new.work_off(1)
|
206
|
-
expect(CompletionJob.invoked).to be(false)
|
206
|
+
expect(TestJobs::CompletionJob.invoked).to be(false)
|
207
207
|
expect(job_group_count).to eq 0
|
208
208
|
expect(Delayed::Job.count).to eq 1
|
209
209
|
|
210
210
|
# Now we should run the completion job
|
211
211
|
Delayed::Worker.new.work_off(1)
|
212
|
-
expect(CompletionJob.invoked).to be(true)
|
212
|
+
expect(TestJobs::CompletionJob.invoked).to be(true)
|
213
213
|
expect(Delayed::Job.count).to eq 0
|
214
214
|
end
|
215
215
|
|
216
216
|
context "when a cancellation job is provided" do
|
217
217
|
let!(:job_group) do
|
218
|
-
Delayed::JobGroups::JobGroup.create!(on_completion_job: CompletionJob.new,
|
219
|
-
on_cancellation_job: CancellationJob.new)
|
218
|
+
Delayed::JobGroups::JobGroup.create!(on_completion_job: TestJobs::CompletionJob.new,
|
219
|
+
on_cancellation_job: TestJobs::CancellationJob.new)
|
220
220
|
end
|
221
221
|
|
222
222
|
it "runs the cancellation job after a job error causes cancellation" do
|
223
223
|
Delayed::Worker.max_attempts = 1
|
224
224
|
|
225
|
-
job_group.enqueue(FailingJob.new)
|
226
|
-
job_group.enqueue(NoOpJob.new)
|
225
|
+
job_group.enqueue(TestJobs::FailingJob.new)
|
226
|
+
job_group.enqueue(TestJobs::NoOpJob.new)
|
227
227
|
job_group.mark_queueing_complete
|
228
228
|
expect(queued_job_count).to eq 2
|
229
229
|
expect(job_group_count).to eq 1
|
230
230
|
|
231
231
|
# Run the job which should fail and cancel the JobGroup
|
232
232
|
Delayed::Worker.new.work_off(1)
|
233
|
-
expect(CompletionJob.invoked).to be(false)
|
234
|
-
expect(CancellationJob.invoked).to be(false)
|
233
|
+
expect(TestJobs::CompletionJob.invoked).to be(false)
|
234
|
+
expect(TestJobs::CancellationJob.invoked).to be(false)
|
235
235
|
expect(failed_job_count).to eq 1
|
236
236
|
|
237
237
|
expect(queued_job_count).to eq 1
|
@@ -239,24 +239,24 @@ describe Delayed::JobGroups::Plugin do
|
|
239
239
|
|
240
240
|
# Now we should run the cancellation job
|
241
241
|
Delayed::Worker.new.work_off(1)
|
242
|
-
expect(CompletionJob.invoked).to be(false)
|
243
|
-
expect(CancellationJob.invoked).to be(true)
|
242
|
+
expect(TestJobs::CompletionJob.invoked).to be(false)
|
243
|
+
expect(TestJobs::CancellationJob.invoked).to be(true)
|
244
244
|
expect(queued_job_count).to eq 0
|
245
245
|
end
|
246
246
|
|
247
247
|
it "runs the cancellation job after the job group is cancelled" do
|
248
|
-
job_group.enqueue(NoOpJob.new)
|
249
|
-
job_group.enqueue(FailingJob.new)
|
248
|
+
job_group.enqueue(TestJobs::NoOpJob.new)
|
249
|
+
job_group.enqueue(TestJobs::FailingJob.new)
|
250
250
|
job_group.mark_queueing_complete
|
251
251
|
job_group.cancel
|
252
252
|
|
253
253
|
# cancellation job should be queued
|
254
254
|
expect(queued_job_count).to eq 1
|
255
|
-
expect(CancellationJob.invoked).to be(false)
|
255
|
+
expect(TestJobs::CancellationJob.invoked).to be(false)
|
256
256
|
|
257
257
|
# Run the cancellation job
|
258
258
|
Delayed::Worker.new.work_off(1)
|
259
|
-
expect(CancellationJob.invoked).to be(true)
|
259
|
+
expect(TestJobs::CancellationJob.invoked).to be(true)
|
260
260
|
expect(queued_job_count).to eq 0
|
261
261
|
end
|
262
262
|
end
|
@@ -265,8 +265,8 @@ describe Delayed::JobGroups::Plugin do
|
|
265
265
|
let!(:job_group) { Delayed::JobGroups::JobGroup.create! }
|
266
266
|
|
267
267
|
it "doesn't queue a non-existent completion job" do
|
268
|
-
job_group.enqueue(NoOpJob.new)
|
269
|
-
job_group.enqueue(NoOpJob.new)
|
268
|
+
job_group.enqueue(TestJobs::NoOpJob.new)
|
269
|
+
job_group.enqueue(TestJobs::NoOpJob.new)
|
270
270
|
job_group.mark_queueing_complete
|
271
271
|
expect(job_group_count).to eq 1
|
272
272
|
expect(queued_job_count).to eq 2
|
@@ -286,37 +286,6 @@ describe Delayed::JobGroups::Plugin do
|
|
286
286
|
end
|
287
287
|
end
|
288
288
|
|
289
|
-
class FailingJob
|
290
|
-
|
291
|
-
def perform
|
292
|
-
raise 'Test failure'
|
293
|
-
end
|
294
|
-
|
295
|
-
end
|
296
|
-
|
297
|
-
class NoOpJob
|
298
|
-
|
299
|
-
def perform
|
300
|
-
|
301
|
-
end
|
302
|
-
end
|
303
|
-
|
304
|
-
class CompletionJob
|
305
|
-
cattr_accessor :invoked
|
306
|
-
|
307
|
-
def perform
|
308
|
-
CompletionJob.invoked = true
|
309
|
-
end
|
310
|
-
end
|
311
|
-
|
312
|
-
class CancellationJob
|
313
|
-
cattr_accessor :invoked
|
314
|
-
|
315
|
-
def perform
|
316
|
-
CancellationJob.invoked = true
|
317
|
-
end
|
318
|
-
end
|
319
|
-
|
320
289
|
def job_group_count
|
321
290
|
Delayed::JobGroups::JobGroup.count
|
322
291
|
end
|
@@ -1,14 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
describe Delayed::JobGroups::YamlLoader do
|
4
|
-
class Foo; end
|
5
|
-
|
6
4
|
describe "#load" do
|
7
5
|
context "with a correct yaml object representation" do
|
8
|
-
let(:yaml) { '--- !ruby/object:Foo {}' }
|
6
|
+
let(:yaml) { '--- !ruby/object:TestJobs::Foo {}' }
|
9
7
|
|
10
8
|
it "deserializes from YAML properly" do
|
11
|
-
expect(Delayed::JobGroups::YamlLoader.load(yaml)).to be_a(Foo)
|
9
|
+
expect(Delayed::JobGroups::YamlLoader.load(yaml)).to be_a(TestJobs::Foo)
|
12
10
|
end
|
13
11
|
end
|
14
12
|
|
@@ -25,10 +23,10 @@ describe Delayed::JobGroups::YamlLoader do
|
|
25
23
|
|
26
24
|
describe "#dump" do
|
27
25
|
context "with an object" do
|
28
|
-
let(:object) { Foo.new }
|
26
|
+
let(:object) { TestJobs::Foo.new }
|
29
27
|
|
30
28
|
it "serializes into YAML properly" do
|
31
|
-
expect(Delayed::JobGroups::YamlLoader.dump(object)).to eq("--- !ruby/object:Foo {}\n")
|
29
|
+
expect(Delayed::JobGroups::YamlLoader.dump(object)).to eq("--- !ruby/object:TestJobs::Foo {}\n")
|
32
30
|
end
|
33
31
|
end
|
34
32
|
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TestJobs
|
4
|
+
class Foo; end
|
5
|
+
|
6
|
+
class FailingJob
|
7
|
+
def perform
|
8
|
+
raise 'Test failure'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class NoOpJob
|
13
|
+
def perform
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class CompletionJob
|
19
|
+
cattr_accessor :invoked
|
20
|
+
|
21
|
+
def perform
|
22
|
+
CompletionJob.invoked = true
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
class CancellationJob
|
27
|
+
cattr_accessor :invoked
|
28
|
+
|
29
|
+
def perform
|
30
|
+
CancellationJob.invoked = true
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
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.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joel Turkel
|
8
8
|
- Randy Burkes
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2022-04-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: delayed_job
|
@@ -62,7 +62,7 @@ dependencies:
|
|
62
62
|
version: '5.2'
|
63
63
|
- - "<"
|
64
64
|
- !ruby/object:Gem::Version
|
65
|
-
version: '7'
|
65
|
+
version: '7.1'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
68
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -72,7 +72,7 @@ dependencies:
|
|
72
72
|
version: '5.2'
|
73
73
|
- - "<"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '7'
|
75
|
+
version: '7.1'
|
76
76
|
- !ruby/object:Gem::Dependency
|
77
77
|
name: coveralls_reborn
|
78
78
|
requirement: !ruby/object:Gem::Requirement
|
@@ -175,16 +175,16 @@ dependencies:
|
|
175
175
|
name: salsify_rubocop
|
176
176
|
requirement: !ruby/object:Gem::Requirement
|
177
177
|
requirements:
|
178
|
-
- -
|
178
|
+
- - "~>"
|
179
179
|
- !ruby/object:Gem::Version
|
180
|
-
version: 0.
|
180
|
+
version: 1.0.1
|
181
181
|
type: :development
|
182
182
|
prerelease: false
|
183
183
|
version_requirements: !ruby/object:Gem::Requirement
|
184
184
|
requirements:
|
185
|
-
- -
|
185
|
+
- - "~>"
|
186
186
|
- !ruby/object:Gem::Version
|
187
|
-
version: 0.
|
187
|
+
version: 1.0.1
|
188
188
|
- !ruby/object:Gem::Dependency
|
189
189
|
name: simplecov
|
190
190
|
requirement: !ruby/object:Gem::Requirement
|
@@ -237,6 +237,7 @@ extensions: []
|
|
237
237
|
extra_rdoc_files: []
|
238
238
|
files:
|
239
239
|
- ".circleci/config.yml"
|
240
|
+
- ".github/CODEOWNERS"
|
240
241
|
- ".gitignore"
|
241
242
|
- ".rspec"
|
242
243
|
- ".rubocop.yml"
|
@@ -247,13 +248,14 @@ files:
|
|
247
248
|
- README.md
|
248
249
|
- Rakefile
|
249
250
|
- delayed_job_groups.gemspec
|
250
|
-
- gemfiles/rails_5.2.gemfile
|
251
251
|
- gemfiles/rails_6.0.gemfile
|
252
252
|
- gemfiles/rails_6.1.gemfile
|
253
|
+
- gemfiles/rails_7.0.gemfile
|
253
254
|
- lib/delayed/job_groups/compatibility.rb
|
254
255
|
- lib/delayed/job_groups/job_extensions.rb
|
255
256
|
- lib/delayed/job_groups/job_group.rb
|
256
257
|
- lib/delayed/job_groups/plugin.rb
|
258
|
+
- lib/delayed/job_groups/railtie.rb
|
257
259
|
- lib/delayed/job_groups/version.rb
|
258
260
|
- lib/delayed/job_groups/yaml_loader.rb
|
259
261
|
- lib/delayed_job_groups_plugin.rb
|
@@ -261,15 +263,19 @@ files:
|
|
261
263
|
- lib/generators/delayed_job_groups_plugin/templates/migration.erb
|
262
264
|
- spec/db/database.yml
|
263
265
|
- spec/db/schema.rb
|
266
|
+
- spec/delayed/job_groups/job_extensions_spec.rb
|
264
267
|
- spec/delayed/job_groups/job_group_spec.rb
|
265
268
|
- spec/delayed/job_groups/plugin_spec.rb
|
266
269
|
- spec/delayed/job_groups/yaml_loader_spec.rb
|
267
270
|
- spec/spec_helper.rb
|
268
271
|
- spec/support/destroyed_model.rb
|
272
|
+
- spec/support/test_jobs.rb
|
269
273
|
homepage: https://github.com/salsify/delayed_job_groups_plugin
|
270
274
|
licenses:
|
271
275
|
- MIT
|
272
|
-
metadata:
|
276
|
+
metadata:
|
277
|
+
allowed_push_host: https://rubygems.org
|
278
|
+
rubygems_mfa_required: 'true'
|
273
279
|
post_install_message: See https://github.com/salsify/delayed_job_groups_plugin#installation
|
274
280
|
for upgrade/installation notes.
|
275
281
|
rdoc_options: []
|
@@ -279,22 +285,24 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
279
285
|
requirements:
|
280
286
|
- - ">="
|
281
287
|
- !ruby/object:Gem::Version
|
282
|
-
version: '2.
|
288
|
+
version: '2.7'
|
283
289
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
284
290
|
requirements:
|
285
291
|
- - ">="
|
286
292
|
- !ruby/object:Gem::Version
|
287
293
|
version: '0'
|
288
294
|
requirements: []
|
289
|
-
rubygems_version: 3.
|
290
|
-
signing_key:
|
295
|
+
rubygems_version: 3.2.33
|
296
|
+
signing_key:
|
291
297
|
specification_version: 4
|
292
298
|
summary: Delayed::Job job groups plugin
|
293
299
|
test_files:
|
294
|
-
- spec/
|
295
|
-
- spec/
|
296
|
-
- spec/delayed/job_groups/
|
300
|
+
- spec/db/database.yml
|
301
|
+
- spec/db/schema.rb
|
302
|
+
- spec/delayed/job_groups/job_extensions_spec.rb
|
297
303
|
- spec/delayed/job_groups/job_group_spec.rb
|
304
|
+
- spec/delayed/job_groups/plugin_spec.rb
|
298
305
|
- spec/delayed/job_groups/yaml_loader_spec.rb
|
299
|
-
- spec/
|
300
|
-
- spec/
|
306
|
+
- spec/spec_helper.rb
|
307
|
+
- spec/support/destroyed_model.rb
|
308
|
+
- spec/support/test_jobs.rb
|