good_job 3.14.0 → 3.14.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/app/models/good_job/execution.rb +7 -1
- data/app/models/good_job/job.rb +24 -4
- data/lib/good_job/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d3457088e2e7120f5660f8c1395adb27887a0aad22d7b2ec816060f7619ebec
|
4
|
+
data.tar.gz: a6978f42d4a988b202c891633a8390dd585edbc07cf11f35511aaca005ce67e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5226e5cf17704c8cf1eaa0401fd3bc384d892bb02d6538653bde412b9f627537ba333816e589a05089f590df0d602ab163e57f2cdd4452e5ba539a9c57b7ff3
|
7
|
+
data.tar.gz: 49529f8c59b0a62cf6fe0f91b848ef01979c6e245b23e71cc2be3939c3497a6edfe92cb66c6171722e6473ba1d2d759a427855665a6419344ad0dbff69c73783
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [v3.14.1](https://github.com/bensheldon/good_job/tree/v3.14.1) (2023-03-14)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/bensheldon/good_job/compare/v3.14.0...v3.14.1)
|
6
|
+
|
7
|
+
**Merged pull requests:**
|
8
|
+
|
9
|
+
- Allow joining executions to jobs scoped by state [\#886](https://github.com/bensheldon/good_job/pull/886) ([segiddins](https://github.com/segiddins))
|
10
|
+
- Add execution\_result to event payload for perform\_job.good\_job [\#885](https://github.com/bensheldon/good_job/pull/885) ([segiddins](https://github.com/segiddins))
|
11
|
+
- Bump rack from 2.2.6.2 to 2.2.6.3 [\#884](https://github.com/bensheldon/good_job/pull/884) ([dependabot[bot]](https://github.com/apps/dependabot))
|
12
|
+
|
3
13
|
## [v3.14.0](https://github.com/bensheldon/good_job/tree/v3.14.0) (2023-03-09)
|
4
14
|
|
5
15
|
[Full Changelog](https://github.com/bensheldon/good_job/compare/v3.13.0...v3.14.0)
|
@@ -336,7 +336,7 @@ module GoodJob
|
|
336
336
|
current_thread.execution_interrupted = performed_at if performed_at
|
337
337
|
update!(performed_at: Time.current)
|
338
338
|
|
339
|
-
ActiveSupport::Notifications.instrument("perform_job.good_job", { execution: self, process_id: current_thread.process_id, thread_name: current_thread.thread_name }) do
|
339
|
+
ActiveSupport::Notifications.instrument("perform_job.good_job", { execution: self, process_id: current_thread.process_id, thread_name: current_thread.thread_name }) do |instrument_payload|
|
340
340
|
value = ActiveJob::Base.execute(active_job_data)
|
341
341
|
|
342
342
|
if value.is_a?(Exception)
|
@@ -345,8 +345,14 @@ module GoodJob
|
|
345
345
|
end
|
346
346
|
handled_error ||= current_thread.error_on_retry || current_thread.error_on_discard
|
347
347
|
|
348
|
+
instrument_payload.merge!(
|
349
|
+
value: value,
|
350
|
+
handled_error: handled_error,
|
351
|
+
retried: current_thread.error_on_retry.present?
|
352
|
+
)
|
348
353
|
ExecutionResult.new(value: value, handled_error: handled_error, retried: current_thread.error_on_retry.present?)
|
349
354
|
rescue StandardError => e
|
355
|
+
instrument_payload[:unhandled_error] = e
|
350
356
|
ExecutionResult.new(value: nil, unhandled_error: e)
|
351
357
|
end
|
352
358
|
end
|
data/app/models/good_job/job.rb
CHANGED
@@ -23,6 +23,26 @@ module GoodJob
|
|
23
23
|
def table_name=(_value)
|
24
24
|
raise NotImplementedError, 'Assign GoodJob::Execution.table_name directly'
|
25
25
|
end
|
26
|
+
|
27
|
+
def json_string(json, attr)
|
28
|
+
Arel::Nodes::Grouping.new(Arel::Nodes::InfixOperation.new('->>', json, Arel::Nodes.build_quoted(attr)))
|
29
|
+
end
|
30
|
+
|
31
|
+
def params_job_class
|
32
|
+
json_string(arel_table['serialized_params'], 'job_class')
|
33
|
+
end
|
34
|
+
|
35
|
+
def params_execution_count
|
36
|
+
Arel::Nodes::InfixOperation.new(
|
37
|
+
'::',
|
38
|
+
json_string(arel_table['serialized_params'], 'executions'),
|
39
|
+
Arel.sql('integer')
|
40
|
+
)
|
41
|
+
end
|
42
|
+
|
43
|
+
def coalesce_scheduled_at_created_at
|
44
|
+
arel_table.coalesce(arel_table['scheduled_at'], arel_table['created_at'])
|
45
|
+
end
|
26
46
|
end
|
27
47
|
|
28
48
|
self.primary_key = 'active_job_id'
|
@@ -39,7 +59,7 @@ module GoodJob
|
|
39
59
|
# @!scope class
|
40
60
|
# @param string [String] Execution class name
|
41
61
|
# @return [ActiveRecord::Relation]
|
42
|
-
scope :job_class, ->(
|
62
|
+
scope :job_class, ->(name) { where(params_job_class.eq(name)) }
|
43
63
|
|
44
64
|
# Get Jobs finished before the given timestamp.
|
45
65
|
# @!method finished_before(timestamp)
|
@@ -49,11 +69,11 @@ module GoodJob
|
|
49
69
|
scope :finished_before, ->(timestamp) { where(arel_table['finished_at'].lteq(timestamp)) }
|
50
70
|
|
51
71
|
# First execution will run in the future
|
52
|
-
scope :scheduled, -> { where(finished_at: nil).where(
|
72
|
+
scope :scheduled, -> { where(finished_at: nil).where(coalesce_scheduled_at_created_at.gt(DateTime.current)).where(params_execution_count.lt(2)) }
|
53
73
|
# Execution errored, will run in the future
|
54
|
-
scope :retried, -> { where(finished_at: nil).where(
|
74
|
+
scope :retried, -> { where(finished_at: nil).where(coalesce_scheduled_at_created_at.gt(DateTime.current)).where(params_execution_count.gt(1)) }
|
55
75
|
# Immediate/Scheduled time to run has passed, waiting for an available thread run
|
56
|
-
scope :queued, -> { where(finished_at: nil).where(
|
76
|
+
scope :queued, -> { where(finished_at: nil).where(coalesce_scheduled_at_created_at.lteq(DateTime.current)).joins_advisory_locks.where(pg_locks: { locktype: nil }) }
|
57
77
|
# Advisory locked and executing
|
58
78
|
scope :running, -> { where(finished_at: nil).joins_advisory_locks.where.not(pg_locks: { locktype: nil }) }
|
59
79
|
# Finished executing (succeeded or discarded)
|
data/lib/good_job/version.rb
CHANGED
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.14.
|
4
|
+
version: 3.14.1
|
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-03-
|
11
|
+
date: 2023-03-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activejob
|
@@ -460,7 +460,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
460
460
|
- !ruby/object:Gem::Version
|
461
461
|
version: '0'
|
462
462
|
requirements: []
|
463
|
-
rubygems_version: 3.4.
|
463
|
+
rubygems_version: 3.4.8
|
464
464
|
signing_key:
|
465
465
|
specification_version: 4
|
466
466
|
summary: A multithreaded, Postgres-based ActiveJob backend for Ruby on Rails
|