rocketjob 2.1.2 → 2.1.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/lib/rocket_job/plugins/restart.rb +5 -4
- data/lib/rocket_job/version.rb +1 -1
- data/test/plugins/restart_test.rb +13 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69c06ffc4a4e337c787f06d36873d763ccced1be
|
4
|
+
data.tar.gz: 401c2bda273c7413b0ceda2853aef6c325b15159
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87d8f78b0e766a6d1ab06efb00ff83a3b7b27ade12d11109630f01bed3a753ba8f1fe6241d198209870657ee2e6256d5f6c6ba49293c21ad6dc305c85cc4835e
|
7
|
+
data.tar.gz: d87017700e5fb67815b6ce934b73a683d4c08d96ed04e5f802e58ced4a4aa28b2c67be371258c6f643edb6444f90d66e57f0dc1d698b7398dd199bb80eb1d4c6
|
@@ -17,10 +17,11 @@ module RocketJob
|
|
17
17
|
module Restart
|
18
18
|
extend ActiveSupport::Concern
|
19
19
|
|
20
|
-
# Attributes to exclude when copying across the attributes to the new instance
|
21
|
-
RESTART_EXCLUDES = %w(_id state created_at started_at completed_at failure_count worker_name percent_complete exception result run_at record_count sub_state)
|
22
|
-
|
23
20
|
included do
|
21
|
+
# Attributes to exclude when copying across the attributes to the new instance
|
22
|
+
class_attribute :rocket_job_restart_excludes
|
23
|
+
self.rocket_job_restart_excludes = %w(_id state created_at started_at completed_at failure_count worker_name percent_complete exception result run_at record_count sub_state)
|
24
|
+
|
24
25
|
after_abort :rocket_job_restart_new_instance
|
25
26
|
after_complete :rocket_job_restart_new_instance
|
26
27
|
after_fail :rocket_job_restart_abort
|
@@ -32,7 +33,7 @@ module RocketJob
|
|
32
33
|
def rocket_job_restart_new_instance
|
33
34
|
return if expired?
|
34
35
|
attrs = attributes.dup
|
35
|
-
|
36
|
+
rocket_job_restart_excludes.each { |attr| attrs.delete(attr) }
|
36
37
|
|
37
38
|
# Copy across run_at for future dated jobs
|
38
39
|
attrs['run_at'] = run_at if run_at && (run_at > Time.now)
|
data/lib/rocket_job/version.rb
CHANGED
@@ -6,7 +6,15 @@ module Plugins
|
|
6
6
|
class RestartableJob < RocketJob::Job
|
7
7
|
include RocketJob::Plugins::Restart
|
8
8
|
|
9
|
+
# Ensure a new start_at and end_at is generated every time this job is restarted
|
10
|
+
self.rocket_job_restart_excludes = self.rocket_job_restart_excludes + %w(start_at end_at)
|
11
|
+
|
12
|
+
key :start_at, Date
|
13
|
+
key :end_at, Date
|
14
|
+
|
9
15
|
def perform
|
16
|
+
self.start_at = Date.today
|
17
|
+
self.end_at = Date.today
|
10
18
|
'DONE'
|
11
19
|
end
|
12
20
|
end
|
@@ -147,11 +155,14 @@ module Plugins
|
|
147
155
|
assert job2.queued?, job2.attributes.ai
|
148
156
|
|
149
157
|
# Copy across all attributes, except
|
150
|
-
|
151
|
-
|
158
|
+
job2.attributes.each_pair do |key, value|
|
159
|
+
refute_equal 'start_at', key, "Should not include start_at in retried job. #{job2.attributes.inspect}"
|
160
|
+
next if RestartableJob.rocket_job_restart_excludes.include?(key)
|
152
161
|
assert_equal value, job2[key], "Attributes are supposed to be copied across. For #{key}"
|
153
162
|
end
|
154
163
|
|
164
|
+
assert_equal nil, job2.start_at
|
165
|
+
assert_equal nil, job2.end_at
|
155
166
|
assert_equal :queued, job2.state
|
156
167
|
assert job2.created_at
|
157
168
|
assert_equal nil, job2.started_at
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rocketjob
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Reid Morrison
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|