delayed_job_groups_plugin 0.4.2 → 0.4.3
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/README.md +2 -1
- data/lib/delayed/job_groups/plugin.rb +9 -2
- data/lib/delayed/job_groups/version.rb +1 -1
- data/spec/delayed/job_groups/plugin_spec.rb +54 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 03a9f0066659dc667431ab9ebc586c2529832d1461258dd6d426f863e5f86d01
|
4
|
+
data.tar.gz: ab1c0829e4734e8582f59b403e51ae9caa2415afa1f871a1bab630b052cbae59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c268e4005abf1659599be599224e0ed2ff67e36f81bfaea8814de515384974ebecab3d60be9b6a985305294d9bb58ebd65c23a5a4ee5fe6300a15b46b7081a0
|
7
|
+
data.tar.gz: 55ab232adbd0e6f36d2dd36d2eab69210bdae606de95eee08de87f98545b650b4e37a9bc8dcf7838a925a3d6750e2cf7690664c0f81df23933eb7cd8bfa8d1ef
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -100,7 +100,8 @@ job_group.cancel
|
|
100
100
|
|
101
101
|
Configuration to allow failed jobs not to cancel the group
|
102
102
|
```ruby
|
103
|
-
# We can optionally pass options that will allow jobs to fail without cancelling the group
|
103
|
+
# We can optionally pass options that will allow jobs to fail without cancelling the group.
|
104
|
+
# This also allows the on_completion job to fire once all jobs have either succeeded or failed.
|
104
105
|
job_group = Delayed::JobGroups::JobGroup.create!(failure_cancels_group: false)
|
105
106
|
```
|
106
107
|
|
@@ -28,8 +28,9 @@ module Delayed
|
|
28
28
|
|
29
29
|
lifecycle.after(:perform) do |_worker, job|
|
30
30
|
# Make sure we only check to see if the job group is complete
|
31
|
-
# if the job succeeded
|
32
|
-
|
31
|
+
# if the job succeeded or the job has failed (maxed out retries) with failure_cancels_group
|
32
|
+
# set to false
|
33
|
+
if job.in_job_group? && (job_completed?(job) || job_acceptably_failed?(job))
|
33
34
|
JobGroup.check_for_completion(job.job_group_id)
|
34
35
|
end
|
35
36
|
end
|
@@ -44,6 +45,12 @@ module Delayed
|
|
44
45
|
# if it has completed
|
45
46
|
job.destroyed?
|
46
47
|
end
|
48
|
+
|
49
|
+
def self.job_acceptably_failed?(job)
|
50
|
+
# Job has set failed_at (retries have maxed out) and failure_cancels_group is false signaling
|
51
|
+
# that the group should complete despite failures.
|
52
|
+
job.failed_at.present? && job.job_group.present? && !job.job_group.failure_cancels_group?
|
53
|
+
end
|
47
54
|
end
|
48
55
|
end
|
49
56
|
end
|
@@ -83,6 +83,7 @@ describe Delayed::JobGroups::Plugin do
|
|
83
83
|
|
84
84
|
# Run the job which should fail and cancel the JobGroup
|
85
85
|
Delayed::Worker.new.work_off(1)
|
86
|
+
# Completion job is not invoked
|
86
87
|
expect(CompletionJob.invoked).to be(false)
|
87
88
|
expect(failed_job_count).to eq 1
|
88
89
|
expect(queued_job_count).to eq 0
|
@@ -109,6 +110,59 @@ describe Delayed::JobGroups::Plugin do
|
|
109
110
|
expect(failed_job_count).to eq 1
|
110
111
|
expect(queued_job_count).to eq 1
|
111
112
|
expect(job_group_count).to eq 1
|
113
|
+
|
114
|
+
# Run the last job
|
115
|
+
Delayed::Worker.new.work_off(1)
|
116
|
+
expect(failed_job_count).to eq 1
|
117
|
+
expect(queued_job_count).to eq 1
|
118
|
+
expect(job_group_count).to eq 0
|
119
|
+
|
120
|
+
# Run the completion job
|
121
|
+
Delayed::Worker.new.work_off(1)
|
122
|
+
# Completion job is invoked
|
123
|
+
expect(CompletionJob.invoked).to be(true)
|
124
|
+
expect(failed_job_count).to eq 1
|
125
|
+
expect(queued_job_count).to eq 0
|
126
|
+
expect(job_group_count).to eq 0
|
127
|
+
end
|
128
|
+
|
129
|
+
it "runs completion job if last job failed" do
|
130
|
+
Delayed::Worker.max_attempts = 2
|
131
|
+
|
132
|
+
job_group.enqueue(NoOpJob.new)
|
133
|
+
job_group.enqueue(FailingJob.new)
|
134
|
+
job_group.mark_queueing_complete
|
135
|
+
expect(queued_job_count).to eq 2
|
136
|
+
expect(job_group_count).to eq 1
|
137
|
+
|
138
|
+
# Run the non failing job
|
139
|
+
Delayed::Worker.new.work_off(1)
|
140
|
+
expect(failed_job_count).to eq 0
|
141
|
+
expect(queued_job_count).to eq 1
|
142
|
+
expect(job_group_count).to eq 1
|
143
|
+
|
144
|
+
# Run the job which should error
|
145
|
+
Delayed::Worker.new.work_off(1)
|
146
|
+
# Completion job is not invoked
|
147
|
+
expect(CompletionJob.invoked).to be(false)
|
148
|
+
expect(failed_job_count).to eq 0
|
149
|
+
expect(queued_job_count).to eq 1
|
150
|
+
expect(job_group_count).to eq 1
|
151
|
+
|
152
|
+
# Run the job again which should fail
|
153
|
+
Timecop.travel(1.minute.from_now)
|
154
|
+
Delayed::Worker.new.work_off(1)
|
155
|
+
expect(failed_job_count).to eq 1
|
156
|
+
expect(queued_job_count).to eq 1
|
157
|
+
expect(job_group_count).to eq 0
|
158
|
+
|
159
|
+
# Run the completion job
|
160
|
+
Delayed::Worker.new.work_off(1)
|
161
|
+
# Completion job is invoked
|
162
|
+
expect(CompletionJob.invoked).to be(true)
|
163
|
+
expect(failed_job_count).to eq 1
|
164
|
+
expect(queued_job_count).to eq 0
|
165
|
+
expect(job_group_count).to eq 0
|
112
166
|
end
|
113
167
|
end
|
114
168
|
end
|
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.
|
4
|
+
version: 0.4.3
|
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: 2020-
|
12
|
+
date: 2020-06-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: delayed_job
|