good_job 3.4.6 → 3.4.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -0
- data/app/assets/good_job/vendor/bootstrap/bootstrap.bundle.min.js +4 -3
- data/app/assets/good_job/vendor/bootstrap/bootstrap.min.css +5 -4
- data/app/models/good_job/execution.rb +12 -3
- data/app/models/good_job/execution_result.rb +5 -1
- data/lib/good_job/version.rb +1 -1
- data/lib/good_job.rb +1 -1
- metadata +2 -2
@@ -66,6 +66,7 @@ module GoodJob
|
|
66
66
|
end
|
67
67
|
|
68
68
|
belongs_to :job, class_name: 'GoodJob::Job', foreign_key: 'active_job_id', primary_key: 'active_job_id', optional: true, inverse_of: :executions
|
69
|
+
after_destroy -> { self.class.active_job_id(active_job_id).delete_all }, if: -> { @_destroy_job }
|
69
70
|
|
70
71
|
# Get Jobs with given ActiveJob ID
|
71
72
|
# @!method active_job_id
|
@@ -298,11 +299,11 @@ module GoodJob
|
|
298
299
|
|
299
300
|
if result.unhandled_error && GoodJob.retry_on_unhandled_error
|
300
301
|
save!
|
301
|
-
elsif GoodJob.preserve_job_records == true || (result.unhandled_error && GoodJob.preserve_job_records == :on_unhandled_error)
|
302
|
+
elsif GoodJob.preserve_job_records == true || result.retried? || (result.unhandled_error && GoodJob.preserve_job_records == :on_unhandled_error)
|
302
303
|
self.finished_at = Time.current
|
303
304
|
save!
|
304
305
|
else
|
305
|
-
|
306
|
+
destroy_job
|
306
307
|
end
|
307
308
|
|
308
309
|
result
|
@@ -354,6 +355,14 @@ module GoodJob
|
|
354
355
|
(finished_at || Time.zone.now) - performed_at if performed_at
|
355
356
|
end
|
356
357
|
|
358
|
+
# Destroys this execution and all executions within the same job
|
359
|
+
def destroy_job
|
360
|
+
@_destroy_job = true
|
361
|
+
destroy!
|
362
|
+
ensure
|
363
|
+
@_destroy_job = false
|
364
|
+
end
|
365
|
+
|
357
366
|
private
|
358
367
|
|
359
368
|
def active_job_data
|
@@ -379,7 +388,7 @@ module GoodJob
|
|
379
388
|
end
|
380
389
|
handled_error ||= current_thread.error_on_retry || current_thread.error_on_discard
|
381
390
|
|
382
|
-
ExecutionResult.new(value: value, handled_error: handled_error)
|
391
|
+
ExecutionResult.new(value: value, handled_error: handled_error, retried: current_thread.error_on_retry.present?)
|
383
392
|
rescue StandardError => e
|
384
393
|
ExecutionResult.new(value: nil, unhandled_error: e)
|
385
394
|
end
|
@@ -8,14 +8,18 @@ module GoodJob
|
|
8
8
|
attr_reader :handled_error
|
9
9
|
# @return [Exception, nil]
|
10
10
|
attr_reader :unhandled_error
|
11
|
+
# @return [Exception, nil]
|
12
|
+
attr_reader :retried
|
13
|
+
alias retried? retried
|
11
14
|
|
12
15
|
# @param value [Object, nil]
|
13
16
|
# @param handled_error [Exception, nil]
|
14
17
|
# @param unhandled_error [Exception, nil]
|
15
|
-
def initialize(value:, handled_error: nil, unhandled_error: nil)
|
18
|
+
def initialize(value:, handled_error: nil, unhandled_error: nil, retried: false)
|
16
19
|
@value = value
|
17
20
|
@handled_error = handled_error
|
18
21
|
@unhandled_error = unhandled_error
|
22
|
+
@retried = retried
|
19
23
|
end
|
20
24
|
end
|
21
25
|
end
|
data/lib/good_job/version.rb
CHANGED
data/lib/good_job.rb
CHANGED
@@ -57,7 +57,7 @@ module GoodJob
|
|
57
57
|
# By default, GoodJob deletes job records after the job is completed successfully.
|
58
58
|
# If you want to preserve jobs for latter inspection, set this to +true+.
|
59
59
|
# If you want to preserve only jobs that finished with error for latter inspection, set this to +:on_unhandled_error+.
|
60
|
-
# @return [Boolean, nil]
|
60
|
+
# @return [Boolean, Symbol, nil]
|
61
61
|
mattr_accessor :preserve_job_records, default: true
|
62
62
|
|
63
63
|
# @!attribute [rw] retry_on_unhandled_error
|
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.4.
|
4
|
+
version: 3.4.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Sheldon
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activejob
|