good_job 4.0.1 → 4.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +40 -0
- data/app/controllers/good_job/application_controller.rb +2 -2
- data/app/models/good_job/base_execution.rb +2 -19
- data/app/models/good_job/base_record.rb +2 -2
- data/app/models/good_job/discrete_execution.rb +5 -0
- data/app/models/good_job/job.rb +2 -2
- data/lib/good_job/cleanup_tracker.rb +1 -1
- data/lib/good_job/configuration.rb +27 -58
- data/lib/good_job/version.rb +1 -1
- data/lib/good_job.rb +7 -6
- 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: 41adaae5b9a9c016ba000f7610efa23d533a177374e61039f135a1d152be146c
|
4
|
+
data.tar.gz: 92443b132e11697ae1ba31758852a818e5fbaf201cf080649f1c948d927265d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 155174df9c9d4daf50f4e898585e2cf40898de46eb5974592acdf32cc435cb4cb13b6d4953862a89a3b8223d7bbd2c9e79c60d4a974642f180092d836d04ebb2
|
7
|
+
data.tar.gz: 84b922a4853ffb85da2380ab80c20b3d7392f403218838c3fdcb8872726d2df469d81edeaa28cb2f5a76401280460839c1d3f6ca1f2c9a98c4a1b275ff99cee4
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,45 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [v4.0.3](https://github.com/bensheldon/good_job/tree/v4.0.3) (2024-07-10)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/bensheldon/good_job/compare/v4.0.2...v4.0.3)
|
6
|
+
|
7
|
+
**Fixed bugs:**
|
8
|
+
|
9
|
+
- Only set duration attribute to interval on Rails 6.1 [\#1412](https://github.com/bensheldon/good_job/pull/1412) ([bdewater-thatch](https://github.com/bdewater-thatch))
|
10
|
+
|
11
|
+
**Closed issues:**
|
12
|
+
|
13
|
+
- GoodJob error: TypeError: can't cast ActiveSupport::Duration \(on v4.0.0\) [\#1413](https://github.com/bensheldon/good_job/issues/1413)
|
14
|
+
- Question: is it possible to clean a set of scheduled jobs \(by class name\) from console? [\#1410](https://github.com/bensheldon/good_job/issues/1410)
|
15
|
+
- "Couldn't find GoodJob::BatchRecord" error [\#1387](https://github.com/bensheldon/good_job/issues/1387)
|
16
|
+
- Empty alerts "\[\]"? [\#1372](https://github.com/bensheldon/good_job/issues/1372)
|
17
|
+
- Release GoodJob 4.0 [\#764](https://github.com/bensheldon/good_job/issues/764)
|
18
|
+
|
19
|
+
**Merged pull requests:**
|
20
|
+
|
21
|
+
- Add Active Support load hooks for Job and \(Discrete\)Execution; move all outside class definition bodies [\#1414](https://github.com/bensheldon/good_job/pull/1414) ([bensheldon](https://github.com/bensheldon))
|
22
|
+
|
23
|
+
## [v4.0.2](https://github.com/bensheldon/good_job/tree/v4.0.2) (2024-07-08)
|
24
|
+
|
25
|
+
[Full Changelog](https://github.com/bensheldon/good_job/compare/v4.0.1...v4.0.2)
|
26
|
+
|
27
|
+
**Fixed bugs:**
|
28
|
+
|
29
|
+
- Fix a rails 6.1 deprecation warning for the duration attribute [\#1408](https://github.com/bensheldon/good_job/pull/1408) ([Earlopain](https://github.com/Earlopain))
|
30
|
+
- Actually remove deprecated configuration for `cleanup_interval_seconds`, `cleanup_interval_jobs`; remove deprecated `Lockable` [\#1406](https://github.com/bensheldon/good_job/pull/1406) ([bensheldon](https://github.com/bensheldon))
|
31
|
+
|
32
|
+
**Closed issues:**
|
33
|
+
|
34
|
+
- PG::UndefinedColumn: ERROR: column good\_job\_processes.lock\_type does not exist [\#1405](https://github.com/bensheldon/good_job/issues/1405)
|
35
|
+
- undefined method `duration=' for an instance of GoodJob::Execution [\#1404](https://github.com/bensheldon/good_job/issues/1404)
|
36
|
+
- v3 deprecations are still present [\#1399](https://github.com/bensheldon/good_job/issues/1399)
|
37
|
+
|
38
|
+
**Merged pull requests:**
|
39
|
+
|
40
|
+
- Fix Batch integration test to not exhaust database connection thread pool [\#1409](https://github.com/bensheldon/good_job/pull/1409) ([bensheldon](https://github.com/bensheldon))
|
41
|
+
- Discrete cleanup [\#1401](https://github.com/bensheldon/good_job/pull/1401) ([Earlopain](https://github.com/Earlopain))
|
42
|
+
|
3
43
|
## [v4.0.1](https://github.com/bensheldon/good_job/tree/v4.0.1) (2024-07-08)
|
4
44
|
|
5
45
|
[Full Changelog](https://github.com/bensheldon/good_job/compare/v4.0.0...v4.0.1)
|
@@ -25,6 +25,8 @@ module GoodJob
|
|
25
25
|
self.advisory_lockable_column = 'active_job_id'
|
26
26
|
self.implicit_order_column = 'created_at'
|
27
27
|
|
28
|
+
self.ignored_columns += ["is_discrete"]
|
29
|
+
|
28
30
|
define_model_callbacks :perform
|
29
31
|
define_model_callbacks :perform_unlocked, only: :after
|
30
32
|
|
@@ -216,14 +218,6 @@ module GoodJob
|
|
216
218
|
def coalesce_scheduled_at_created_at
|
217
219
|
arel_table.coalesce(arel_table['scheduled_at'], arel_table['created_at'])
|
218
220
|
end
|
219
|
-
|
220
|
-
def discrete_support?
|
221
|
-
true
|
222
|
-
end
|
223
|
-
end
|
224
|
-
|
225
|
-
def discrete?
|
226
|
-
is_discrete?
|
227
221
|
end
|
228
222
|
|
229
223
|
# Build an ActiveJob instance and deserialize the arguments, using `#active_job_data`.
|
@@ -545,17 +539,6 @@ module GoodJob
|
|
545
539
|
false
|
546
540
|
end
|
547
541
|
|
548
|
-
def make_discrete
|
549
|
-
self.is_discrete = true
|
550
|
-
self.id = active_job_id
|
551
|
-
self.job_class = serialized_params['job_class']
|
552
|
-
self.executions_count ||= 0
|
553
|
-
|
554
|
-
current_time = Time.current
|
555
|
-
self.created_at ||= current_time
|
556
|
-
self.scheduled_at ||= current_time
|
557
|
-
end
|
558
|
-
|
559
542
|
# Return formatted serialized_params for display in the dashboard
|
560
543
|
# @return [Hash]
|
561
544
|
def display_serialized_params
|
@@ -43,7 +43,7 @@ module GoodJob
|
|
43
43
|
def self.bind_value(name, value, type_class)
|
44
44
|
Arel::Nodes::BindParam.new(ActiveRecord::Relation::QueryAttribute.new(name, value, type_class.new))
|
45
45
|
end
|
46
|
-
|
47
|
-
ActiveSupport.run_load_hooks(:good_job_base_record, self)
|
48
46
|
end
|
49
47
|
end
|
48
|
+
|
49
|
+
ActiveSupport.run_load_hooks(:good_job_base_record, GoodJob::BaseRecord)
|
@@ -14,6 +14,9 @@ module GoodJob # :nodoc:
|
|
14
14
|
|
15
15
|
alias_attribute :performed_at, :created_at
|
16
16
|
|
17
|
+
# TODO: Remove when support for Rails 6.1 is dropped
|
18
|
+
attribute :duration, :interval if ActiveJob.version.canonical_segments.take(2) == [6, 1]
|
19
|
+
|
17
20
|
def number
|
18
21
|
serialized_params.fetch('executions', 0) + 1
|
19
22
|
end
|
@@ -57,3 +60,5 @@ module GoodJob # :nodoc:
|
|
57
60
|
end
|
58
61
|
end
|
59
62
|
end
|
63
|
+
|
64
|
+
ActiveSupport.run_load_hooks(:good_job_execution, GoodJob::DiscreteExecution)
|
data/app/models/good_job/job.rb
CHANGED
@@ -46,8 +46,6 @@ module GoodJob
|
|
46
46
|
# Errored but will not be retried
|
47
47
|
scope :discarded, -> { finished.where.not(error: nil) }
|
48
48
|
|
49
|
-
scope :unfinished_undiscrete, -> { where(finished_at: nil, retried_good_job_id: nil, is_discrete: [nil, false]) }
|
50
|
-
|
51
49
|
# TODO: it would be nice to enforce these values at the model
|
52
50
|
# validates :active_job_id, presence: true
|
53
51
|
# validates :scheduled_at, presence: true
|
@@ -226,3 +224,5 @@ module GoodJob
|
|
226
224
|
end
|
227
225
|
end
|
228
226
|
end
|
227
|
+
|
228
|
+
ActiveSupport.run_load_hooks(:good_job_job, GoodJob::Job)
|
@@ -9,7 +9,7 @@ module GoodJob # :nodoc:
|
|
9
9
|
:last_at
|
10
10
|
|
11
11
|
def initialize(cleanup_interval_seconds: false, cleanup_interval_jobs: false)
|
12
|
-
raise ArgumentError, "Do not use `0
|
12
|
+
raise ArgumentError, "Do not use `0` for cleanup intervals. Use `false` to disable, or -1 to always run" if cleanup_interval_seconds == 0 || cleanup_interval_jobs == 0 # rubocop:disable Style/NumericPredicate
|
13
13
|
|
14
14
|
self.cleanup_interval_seconds = cleanup_interval_seconds
|
15
15
|
self.cleanup_interval_jobs = cleanup_interval_jobs
|
@@ -230,8 +230,8 @@ module GoodJob
|
|
230
230
|
def queue_select_limit
|
231
231
|
(
|
232
232
|
options[:queue_select_limit] ||
|
233
|
-
|
234
|
-
|
233
|
+
rails_config[:queue_select_limit] ||
|
234
|
+
env['GOOD_JOB_QUEUE_SELECT_LIMIT']
|
235
235
|
)&.to_i
|
236
236
|
end
|
237
237
|
|
@@ -240,8 +240,8 @@ module GoodJob
|
|
240
240
|
def idle_timeout
|
241
241
|
(
|
242
242
|
options[:idle_timeout] ||
|
243
|
-
|
244
|
-
|
243
|
+
rails_config[:idle_timeout] ||
|
244
|
+
env['GOOD_JOB_IDLE_TIMEOUT']
|
245
245
|
)&.to_i || nil
|
246
246
|
end
|
247
247
|
|
@@ -269,69 +269,38 @@ module GoodJob
|
|
269
269
|
# Positive values will clean up after that many jobs have run, false or 0 will disable, and -1 will clean up after every job.
|
270
270
|
# @return [Integer, Boolean, nil]
|
271
271
|
def cleanup_interval_jobs
|
272
|
-
if rails_config.key?(:cleanup_interval_jobs)
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
)
|
283
|
-
value = -1
|
284
|
-
end
|
285
|
-
elsif env.key?('GOOD_JOB_CLEANUP_INTERVAL_JOBS')
|
286
|
-
value = env['GOOD_JOB_CLEANUP_INTERVAL_JOBS']
|
287
|
-
if value.blank?
|
288
|
-
GoodJob.deprecator.warn(
|
289
|
-
%(Setting `GOOD_JOB_CLEANUP_INTERVAL_JOBS` to `""` will no longer disable count-based cleanups in GoodJob v4. Set to `0` to disable, or `-1` to run every time.)
|
290
|
-
)
|
291
|
-
value = false
|
292
|
-
elsif value == '0'
|
293
|
-
value = false
|
294
|
-
end
|
272
|
+
value = if rails_config.key?(:cleanup_interval_jobs)
|
273
|
+
rails_config[:cleanup_interval_jobs]
|
274
|
+
elsif env.key?('GOOD_JOB_CLEANUP_INTERVAL_JOBS')
|
275
|
+
env['GOOD_JOB_CLEANUP_INTERVAL_JOBS']
|
276
|
+
end
|
277
|
+
|
278
|
+
if value.in? [nil, "", true]
|
279
|
+
DEFAULT_CLEANUP_INTERVAL_JOBS
|
280
|
+
elsif value.in? [0, "0", false, "false"]
|
281
|
+
false
|
295
282
|
else
|
296
|
-
value
|
283
|
+
value ? value.to_i : false
|
297
284
|
end
|
298
|
-
|
299
|
-
value ? value.to_i : false
|
300
285
|
end
|
301
286
|
|
302
287
|
# Number of seconds a {Scheduler} will wait before automatically cleaning up preserved jobs.
|
303
288
|
# Positive values will clean up after that many jobs have run, false or 0 will disable, and -1 will clean up after every job.
|
304
|
-
# @return [Integer, nil]
|
289
|
+
# @return [Integer, Boolean, nil]
|
305
290
|
def cleanup_interval_seconds
|
306
|
-
if rails_config.key?(:cleanup_interval_seconds)
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
%(Setting `config.good_job.cleanup_interval_seconds` to `0` will disable time-based cleanups in GoodJob v4. Set to `false` to disable, or `-1` to run every time.)
|
317
|
-
)
|
318
|
-
value = -1
|
319
|
-
end
|
320
|
-
elsif env.key?('GOOD_JOB_CLEANUP_INTERVAL_SECONDS')
|
321
|
-
value = env['GOOD_JOB_CLEANUP_INTERVAL_SECONDS']
|
322
|
-
if value.blank?
|
323
|
-
GoodJob.deprecator.warn(
|
324
|
-
%(Setting `GOOD_JOB_CLEANUP_INTERVAL_SECONDS` to `""` will no longer disable time-based cleanups in GoodJob v4. Set to `0` to disable, or `-1` to run every time.)
|
325
|
-
)
|
326
|
-
value = false
|
327
|
-
elsif value == '0'
|
328
|
-
value = false
|
329
|
-
end
|
291
|
+
value = if rails_config.key?(:cleanup_interval_seconds)
|
292
|
+
rails_config[:cleanup_interval_seconds]
|
293
|
+
elsif env.key?('GOOD_JOB_CLEANUP_INTERVAL_SECONDS')
|
294
|
+
env['GOOD_JOB_CLEANUP_INTERVAL_SECONDS']
|
295
|
+
end
|
296
|
+
|
297
|
+
if value.nil? || value == "" || value == true
|
298
|
+
DEFAULT_CLEANUP_INTERVAL_SECONDS
|
299
|
+
elsif value.in? [0, "0", false, "false"]
|
300
|
+
false
|
330
301
|
else
|
331
|
-
value
|
302
|
+
value ? value.to_i : false
|
332
303
|
end
|
333
|
-
|
334
|
-
value ? value.to_i : false
|
335
304
|
end
|
336
305
|
|
337
306
|
# Tests whether to daemonize the process.
|
data/lib/good_job/version.rb
CHANGED
data/lib/good_job.rb
CHANGED
@@ -269,7 +269,11 @@ module GoodJob
|
|
269
269
|
# Tests whether GoodJob can be safely upgraded to v4
|
270
270
|
# @return [Boolean]
|
271
271
|
def self.v4_ready?
|
272
|
-
GoodJob
|
272
|
+
GoodJob.deprecator.warn(<<~MSG)
|
273
|
+
Calling `GoodJob.v4_ready?` is deprecated and will be removed in GoodJob v5.
|
274
|
+
If you are reading this deprecation you are already on v4.
|
275
|
+
MSG
|
276
|
+
true
|
273
277
|
end
|
274
278
|
|
275
279
|
# Deprecator for providing deprecation warnings.
|
@@ -281,15 +285,12 @@ module GoodJob
|
|
281
285
|
end
|
282
286
|
end
|
283
287
|
|
284
|
-
include ActiveSupport::Deprecation::DeprecatedConstantAccessor
|
285
|
-
deprecate_constant :Lockable, 'GoodJob::AdvisoryLockable', deprecator: deprecator
|
286
|
-
|
287
288
|
# Whether all GoodJob migrations have been applied.
|
288
289
|
# For use in tests/CI to validate GoodJob is up-to-date.
|
289
290
|
# @return [Boolean]
|
290
291
|
def self.migrated?
|
291
292
|
true
|
292
293
|
end
|
293
|
-
|
294
|
-
ActiveSupport.run_load_hooks(:good_job, self)
|
295
294
|
end
|
295
|
+
|
296
|
+
ActiveSupport.run_load_hooks(:good_job, GoodJob)
|
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: 4.0.
|
4
|
+
version: 4.0.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: 2024-07-
|
11
|
+
date: 2024-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activejob
|