good_job 3.10.0 → 3.10.1
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 +17 -0
- data/app/models/good_job/batch.rb +13 -5
- data/app/models/good_job/batch_record.rb +15 -4
- data/lib/good_job/version.rb +1 -1
- 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: 3e632ae76e69e8601479181fb0093e9c6777510ac0743184a8f578b3c4dacee8
|
|
4
|
+
data.tar.gz: 577f36ad182e6f4ff841abcd073925f4477f1086b1a0c7a454c12037f781ace7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f9211423d43cee468602aa1476d0d4b71a3831448157dc7dc540f98e0d1cb476e60bed884679ef10733af21c21e1c595dac14dc2d1c0b25d4b49b8d246f7be98
|
|
7
|
+
data.tar.gz: 25a51a4196ea6618ca44ac73ed6cb9f97b63d99596bd144a9d51f439033a22d15ab16a73cd9d48954dc9b447b19cc9f03a21a9e5667d5021c85b5510ad7ca577
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [v3.10.1](https://github.com/bensheldon/good_job/tree/v3.10.1) (2023-02-06)
|
|
4
|
+
|
|
5
|
+
[Full Changelog](https://github.com/bensheldon/good_job/compare/v3.10.0...v3.10.1)
|
|
6
|
+
|
|
7
|
+
**Fixed bugs:**
|
|
8
|
+
|
|
9
|
+
- Ensure batch is reloaded before updating on multiple enqueues [\#824](https://github.com/bensheldon/good_job/pull/824) ([bensheldon](https://github.com/bensheldon))
|
|
10
|
+
|
|
11
|
+
**Closed issues:**
|
|
12
|
+
|
|
13
|
+
- Can't batch.enqueue the callback after retrying a job within the batch [\#822](https://github.com/bensheldon/good_job/issues/822)
|
|
14
|
+
|
|
15
|
+
**Merged pull requests:**
|
|
16
|
+
|
|
17
|
+
- In tests, retry when connecting to Puma returns Net::ReadTimeout [\#825](https://github.com/bensheldon/good_job/pull/825) ([bensheldon](https://github.com/bensheldon))
|
|
18
|
+
- Add Batch enqueue example to Demo's cron configuration [\#823](https://github.com/bensheldon/good_job/pull/823) ([bensheldon](https://github.com/bensheldon))
|
|
19
|
+
|
|
3
20
|
## [v3.10.0](https://github.com/bensheldon/good_job/tree/v3.10.0) (2023-02-04)
|
|
4
21
|
|
|
5
22
|
[Full Changelog](https://github.com/bensheldon/good_job/compare/v3.9.0...v3.10.0)
|
|
@@ -86,15 +86,23 @@ module GoodJob
|
|
|
86
86
|
# @return [Array<ActiveJob::Base>] Active jobs added to the batch
|
|
87
87
|
def enqueue(active_jobs = [], **properties, &block)
|
|
88
88
|
assign_properties(properties)
|
|
89
|
-
record.
|
|
89
|
+
if record.new_record?
|
|
90
|
+
record.save!
|
|
91
|
+
else
|
|
92
|
+
record.with_advisory_lock(function: "pg_advisory_lock") do
|
|
93
|
+
record.enqueued_at_will_change!
|
|
94
|
+
record.finished_at_will_change!
|
|
95
|
+
record.update!(enqueued_at: nil, finished_at: nil)
|
|
96
|
+
end
|
|
97
|
+
end
|
|
90
98
|
|
|
91
99
|
active_jobs = add(active_jobs, &block)
|
|
92
100
|
|
|
93
|
-
record.
|
|
94
|
-
|
|
95
|
-
|
|
101
|
+
record.with_advisory_lock(function: "pg_advisory_lock") do
|
|
102
|
+
record.update!(enqueued_at: Time.current)
|
|
103
|
+
record._continue_discard_or_finish(lock: false)
|
|
104
|
+
end
|
|
96
105
|
|
|
97
|
-
record._continue_discard_or_finish
|
|
98
106
|
active_jobs
|
|
99
107
|
end
|
|
100
108
|
|
|
@@ -43,16 +43,17 @@ module GoodJob
|
|
|
43
43
|
attributes.except('serialized_properties').merge(properties: properties)
|
|
44
44
|
end
|
|
45
45
|
|
|
46
|
-
def _continue_discard_or_finish(execution = nil)
|
|
46
|
+
def _continue_discard_or_finish(execution = nil, lock: true)
|
|
47
47
|
execution_discarded = execution && execution.error.present? && execution.retried_good_job_id.nil?
|
|
48
|
-
|
|
48
|
+
take_advisory_lock(lock) do
|
|
49
49
|
Batch.within_thread(batch_id: nil, batch_callback_id: id) do
|
|
50
|
-
|
|
50
|
+
reload
|
|
51
|
+
if execution_discarded && !discarded_at
|
|
51
52
|
update(discarded_at: Time.current)
|
|
52
53
|
on_discard.constantize.set(priority: callback_priority, queue: callback_queue_name).perform_later(to_batch, { event: :discard }) if on_discard.present?
|
|
53
54
|
end
|
|
54
55
|
|
|
55
|
-
if
|
|
56
|
+
if enqueued_at && !finished_at && jobs.where(finished_at: nil).count.zero?
|
|
56
57
|
update(finished_at: Time.current)
|
|
57
58
|
on_success.constantize.set(priority: callback_priority, queue: callback_queue_name).perform_later(to_batch, { event: :success }) if !discarded_at && on_success.present?
|
|
58
59
|
on_finish.constantize.set(priority: callback_priority, queue: callback_queue_name).perform_later(to_batch, { event: :finish }) if on_finish.present?
|
|
@@ -80,5 +81,15 @@ module GoodJob
|
|
|
80
81
|
|
|
81
82
|
self.serialized_properties = value
|
|
82
83
|
end
|
|
84
|
+
|
|
85
|
+
private
|
|
86
|
+
|
|
87
|
+
def take_advisory_lock(value, &block)
|
|
88
|
+
if value
|
|
89
|
+
with_advisory_lock(function: "pg_advisory_lock", &block)
|
|
90
|
+
else
|
|
91
|
+
yield
|
|
92
|
+
end
|
|
93
|
+
end
|
|
83
94
|
end
|
|
84
95
|
end
|
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.10.
|
|
4
|
+
version: 3.10.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-02-
|
|
11
|
+
date: 2023-02-06 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activejob
|