good_job 3.16.2 → 3.16.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 +16 -0
- data/README.md +3 -1
- data/app/models/concerns/good_job/error_events.rb +26 -9
- data/app/models/good_job/base_execution.rb +3 -0
- data/app/models/good_job/execution.rb +1 -5
- data/app/models/good_job/job.rb +6 -7
- data/lib/good_job/adapter.rb +9 -1
- data/lib/good_job/version.rb +1 -1
- data/lib/good_job.rb +9 -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: 3929d3de9d0c69de6aa34b238573dd19eabb0b6753b28a06b186cfc6972b621b
|
|
4
|
+
data.tar.gz: d927b1cc39f993f64a4b07594cb7215975e02d55cb212b420122b2c672d5f2d4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 34ac854233932322ad76eaea4d41879b9d97c08a204b6f689affedbe861b86bc5c83b6c02dd1132c267f7f9129d4e0ace042e9299f4fe522fdf9d590b6c0cf33
|
|
7
|
+
data.tar.gz: a8007ea55894eb72494935dff5269d1e54d157eab334b823769884cc3d83d1a37be3d9cb44e603ba5a132cb3993ba8dd8e306c4d3974f9a2bf4dc2603add5706
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [v3.16.3](https://github.com/bensheldon/good_job/tree/v3.16.3) (2023-07-18)
|
|
4
|
+
|
|
5
|
+
[Full Changelog](https://github.com/bensheldon/good_job/compare/v3.16.2...v3.16.3)
|
|
6
|
+
|
|
7
|
+
**Fixed bugs:**
|
|
8
|
+
|
|
9
|
+
- Fix bulk enqueue for unmigrated 'error\_event'; add `GoodJob.migrated?` check method; use custom enum implementation [\#1011](https://github.com/bensheldon/good_job/pull/1011) ([bensheldon](https://github.com/bensheldon))
|
|
10
|
+
|
|
11
|
+
**Closed issues:**
|
|
12
|
+
|
|
13
|
+
- GoodJob::Bulk.enqueue not handling missing migrations [\#1010](https://github.com/bensheldon/good_job/issues/1010)
|
|
14
|
+
|
|
15
|
+
**Merged pull requests:**
|
|
16
|
+
|
|
17
|
+
- Move shared `BaseExecution` concerns into the base class. [\#1009](https://github.com/bensheldon/good_job/pull/1009) ([dixpac](https://github.com/dixpac))
|
|
18
|
+
|
|
3
19
|
## [v3.16.2](https://github.com/bensheldon/good_job/tree/v3.16.2) (2023-07-13)
|
|
4
20
|
|
|
5
21
|
[Full Changelog](https://github.com/bensheldon/good_job/compare/v3.16.1...v3.16.2)
|
data/README.md
CHANGED
|
@@ -703,7 +703,9 @@ GoodJob follows semantic versioning, though updates may be encouraged through de
|
|
|
703
703
|
|
|
704
704
|
#### Upgrading minor versions
|
|
705
705
|
|
|
706
|
-
Upgrading between minor versions (e.g. v1.4 to v1.5) should not introduce breaking changes, but can introduce new deprecation warnings and database migration
|
|
706
|
+
Upgrading between minor versions (e.g. v1.4 to v1.5) should not introduce breaking changes, but can introduce new deprecation warnings and database migration warnings.
|
|
707
|
+
|
|
708
|
+
Database migrations introduced in minor releases are _not required_ to be applied until the next major release. If you would like apply newly introduced migrations immediately, assert `GoodJob.migrated?` in your application's test suite.
|
|
707
709
|
|
|
708
710
|
To perform upgrades to the GoodJob database tables:
|
|
709
711
|
|
|
@@ -14,15 +14,32 @@ module GoodJob
|
|
|
14
14
|
ERROR_EVENT_DISCARDED = 'discarded',
|
|
15
15
|
].freeze
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
ERROR_EVENT_ENUMS = {
|
|
18
|
+
ERROR_EVENT_INTERRUPTED => 0,
|
|
19
|
+
ERROR_EVENT_UNHANDLED => 1,
|
|
20
|
+
ERROR_EVENT_HANDLED => 2,
|
|
21
|
+
ERROR_EVENT_RETRIED => 3,
|
|
22
|
+
ERROR_EVENT_RETRY_STOPPED => 4,
|
|
23
|
+
ERROR_EVENT_DISCARDED => 5,
|
|
24
|
+
}.freeze
|
|
25
|
+
|
|
26
|
+
# TODO: GoodJob v4 can make this an `enum` once migrations are guaranteed.
|
|
27
|
+
def error_event
|
|
28
|
+
return unless self.class.columns_hash['error_event']
|
|
29
|
+
|
|
30
|
+
enum = super
|
|
31
|
+
return unless enum
|
|
32
|
+
|
|
33
|
+
ERROR_EVENT_ENUMS.key(enum)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def error_event=(event)
|
|
37
|
+
return unless self.class.columns_hash['error_event']
|
|
38
|
+
|
|
39
|
+
enum = ERROR_EVENT_ENUMS[event]
|
|
40
|
+
raise(ArgumentError, "Invalid error_event: #{event}") if event && !enum
|
|
41
|
+
|
|
42
|
+
super(enum)
|
|
26
43
|
end
|
|
27
44
|
end
|
|
28
45
|
end
|
|
@@ -3,10 +3,6 @@
|
|
|
3
3
|
module GoodJob
|
|
4
4
|
# ActiveRecord model that represents an +ActiveJob+ job.
|
|
5
5
|
class Execution < BaseExecution
|
|
6
|
-
include Lockable
|
|
7
|
-
include Filterable
|
|
8
|
-
include Reportable
|
|
9
|
-
|
|
10
6
|
# Raised if something attempts to execute a previously completed Execution again.
|
|
11
7
|
PreviouslyPerformedError = Class.new(StandardError)
|
|
12
8
|
|
|
@@ -384,7 +380,7 @@ module GoodJob
|
|
|
384
380
|
error: interrupt_error_string,
|
|
385
381
|
finished_at: Time.current,
|
|
386
382
|
}
|
|
387
|
-
discrete_execution_attrs[:error_event] = GoodJob::
|
|
383
|
+
discrete_execution_attrs[:error_event] = GoodJob::ErrorEvents::ERROR_EVENT_ENUMS[GoodJob::ErrorEvents::ERROR_EVENT_INTERRUPTED] if self.class.error_event_migrated?
|
|
388
384
|
discrete_executions.where(finished_at: nil).where.not(performed_at: nil).update_all(discrete_execution_attrs) # rubocop:disable Rails/SkipsModelValidations
|
|
389
385
|
end
|
|
390
386
|
end
|
data/app/models/good_job/job.rb
CHANGED
|
@@ -7,10 +7,6 @@ module GoodJob
|
|
|
7
7
|
# A single row from the +good_jobs+ table of executions is fetched to represent a Job.
|
|
8
8
|
#
|
|
9
9
|
class Job < BaseExecution
|
|
10
|
-
include Filterable
|
|
11
|
-
include Lockable
|
|
12
|
-
include Reportable
|
|
13
|
-
|
|
14
10
|
# Raised when an inappropriate action is applied to a Job based on its state.
|
|
15
11
|
ActionForStateMismatchError = Class.new(StandardError)
|
|
16
12
|
# Raised when an action requires GoodJob to be the ActiveJob Queue Adapter but GoodJob is not.
|
|
@@ -228,9 +224,12 @@ module GoodJob
|
|
|
228
224
|
|
|
229
225
|
update_execution = proc do
|
|
230
226
|
execution.update(
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
227
|
+
{
|
|
228
|
+
finished_at: Time.current,
|
|
229
|
+
error: GoodJob::Execution.format_error(job_error),
|
|
230
|
+
}.tap do |attrs|
|
|
231
|
+
attrs[:error_event] = ERROR_EVENT_DISCARDED if self.class.error_event_migrated?
|
|
232
|
+
end
|
|
234
233
|
)
|
|
235
234
|
end
|
|
236
235
|
|
data/lib/good_job/adapter.rb
CHANGED
|
@@ -64,7 +64,15 @@ module GoodJob
|
|
|
64
64
|
|
|
65
65
|
inline_executions = []
|
|
66
66
|
GoodJob::Execution.transaction(requires_new: true, joinable: false) do
|
|
67
|
-
|
|
67
|
+
execution_attributes = executions.map do |execution|
|
|
68
|
+
if GoodJob::Execution.error_event_migrated?
|
|
69
|
+
execution.attributes
|
|
70
|
+
else
|
|
71
|
+
execution.attributes.except('error_event')
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
results = GoodJob::Execution.insert_all(execution_attributes, returning: %w[id active_job_id]) # rubocop:disable Rails/SkipsModelValidations
|
|
68
76
|
|
|
69
77
|
job_id_to_provider_job_id = results.each_with_object({}) { |result, hash| hash[result['active_job_id']] = result['id'] }
|
|
70
78
|
active_jobs.each do |active_job|
|
data/lib/good_job/version.rb
CHANGED
data/lib/good_job.rb
CHANGED
|
@@ -246,5 +246,14 @@ module GoodJob
|
|
|
246
246
|
end
|
|
247
247
|
end
|
|
248
248
|
|
|
249
|
+
# Whether all GoodJob migrations have been applied.
|
|
250
|
+
# For use in tests/CI to validate GoodJob is up-to-date.
|
|
251
|
+
# @return [Boolean]
|
|
252
|
+
def self.migrated?
|
|
253
|
+
# Always update with the most recent migration check
|
|
254
|
+
GoodJob::Execution.reset_column_information
|
|
255
|
+
GoodJob::Execution.error_event_migrated?
|
|
256
|
+
end
|
|
257
|
+
|
|
249
258
|
ActiveSupport.run_load_hooks(:good_job, self)
|
|
250
259
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: good_job
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.16.
|
|
4
|
+
version: 3.16.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ben Sheldon
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2023-07-
|
|
11
|
+
date: 2023-07-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activejob
|