rocketjob 6.0.0 → 6.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rocket_job/batch/categories.rb +11 -13
- data/lib/rocket_job/dirmon_entry.rb +2 -0
- data/lib/rocket_job/job_exception.rb +1 -1
- data/lib/rocket_job/jobs/dirmon_job.rb +22 -14
- data/lib/rocket_job/jobs/on_demand_batch_job.rb +4 -0
- data/lib/rocket_job/jobs/on_demand_job.rb +4 -0
- data/lib/rocket_job/plugins/throttle_dependent_jobs.rb +9 -3
- data/lib/rocket_job/subscribers/secret_config.rb +17 -0
- data/lib/rocket_job/supervisor.rb +1 -0
- data/lib/rocket_job/version.rb +1 -1
- data/lib/rocketjob.rb +2 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc1f3d316be0aa058cee5b22c116872a80ea5bdaf7d72db447ae13781ba6b370
|
4
|
+
data.tar.gz: 87f56a455792e45ab2ad706f0c8bd625590df9942806bbd308c5145d07e94973
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f928a3afb886c39893ef5b5d2e13f71405c83df53c3b02826e474326c9171f87c84e595fc179a0e22cbc69d846f1da12eb268026fc06bcaf609920326159c6f4
|
7
|
+
data.tar.gz: 3b90508c45e7a09739ae53e5bb66992d80251a5b5668eb568eeba30a8da8d109bbb162b2db66e93f82ce3deb4f6cc9425175d0f9c41adb351f6c3885768db3dc
|
@@ -75,27 +75,26 @@ module RocketJob
|
|
75
75
|
return category_name if category_name.is_a?(Category::Input)
|
76
76
|
raise(ArgumentError, "Cannot supply Output Category to input category") if category_name.is_a?(Category::Output)
|
77
77
|
|
78
|
+
# Initialize categories when this method is called before initialization is complete
|
79
|
+
rocketjob_categories_assign if input_categories.empty?
|
80
|
+
|
78
81
|
category_name = category_name.to_sym
|
79
82
|
# find does not work against this association
|
80
83
|
input_categories.each { |category| return category if category.name == category_name }
|
81
84
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
)
|
87
|
-
end
|
88
|
-
|
89
|
-
# Auto-register main input category when not defined
|
90
|
-
category = Category::Input.new(job: self)
|
91
|
-
self.input_categories << category
|
92
|
-
category
|
85
|
+
raise(
|
86
|
+
ArgumentError,
|
87
|
+
"Unknown Input Category: #{category_name.inspect}. Registered categories: #{input_categories.collect(&:name).join(',')}"
|
88
|
+
)
|
93
89
|
end
|
94
90
|
|
95
91
|
def output_category(category_name = :main)
|
96
92
|
return category_name if category_name.is_a?(Category::Output)
|
97
93
|
raise(ArgumentError, "Cannot supply Input Category to output category") if category_name.is_a?(Category::Input)
|
98
94
|
|
95
|
+
# Initialize categories when this method is called before initialization is complete
|
96
|
+
rocketjob_categories_assign if output_categories.empty? && self.class.defined_output_categories
|
97
|
+
|
99
98
|
category_name = category_name.to_sym
|
100
99
|
# .find does not work against this association
|
101
100
|
output_categories.each { |category| return category if category.name == category_name }
|
@@ -154,7 +153,7 @@ module RocketJob
|
|
154
153
|
end
|
155
154
|
end
|
156
155
|
|
157
|
-
return if !
|
156
|
+
return if !output_categories.empty? || !self.class.defined_output_categories
|
158
157
|
|
159
158
|
# Input categories defaults to nil if none was set in the class
|
160
159
|
self.output_categories = self.class.defined_output_categories.deep_dup
|
@@ -164,7 +163,6 @@ module RocketJob
|
|
164
163
|
def rocketjob_categories_output_render
|
165
164
|
return if @rocket_job_output.nil?
|
166
165
|
|
167
|
-
# TODO: ..
|
168
166
|
return unless output_categories
|
169
167
|
return if output_categories.empty?
|
170
168
|
|
@@ -71,6 +71,7 @@ module RocketJob
|
|
71
71
|
validates_presence_of :pattern, :job_class_name, :archive_directory
|
72
72
|
validate :job_is_a_rocket_job
|
73
73
|
validate :job_has_properties
|
74
|
+
validates_uniqueness_of :pattern, :name
|
74
75
|
|
75
76
|
# State Machine events and transitions
|
76
77
|
#
|
@@ -97,6 +98,7 @@ module RocketJob
|
|
97
98
|
event :enable do
|
98
99
|
transitions from: :pending, to: :enabled
|
99
100
|
transitions from: :disabled, to: :enabled
|
101
|
+
transitions from: :failed, to: :enabled
|
100
102
|
end
|
101
103
|
|
102
104
|
event :disable do
|
@@ -59,23 +59,31 @@ module RocketJob
|
|
59
59
|
def check_directories
|
60
60
|
new_file_names = {}
|
61
61
|
DirmonEntry.enabled.each do |dirmon_entry|
|
62
|
-
dirmon_entry
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
dirmon_entry.later(path)
|
67
|
-
next
|
68
|
-
end
|
62
|
+
check_entry(dirmon_entry, new_file_names)
|
63
|
+
end
|
64
|
+
self.previous_file_names = new_file_names
|
65
|
+
end
|
69
66
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
67
|
+
def check_entry(dirmon_entry, file_names)
|
68
|
+
dirmon_entry.each do |path|
|
69
|
+
# Skip file size checking since S3 files are only visible once completely uploaded.
|
70
|
+
unless path.partial_files_visible?
|
71
|
+
logger.info("File: #{path}. Starting: #{dirmon_entry.job_class_name}")
|
72
|
+
dirmon_entry.later(path)
|
73
|
+
next
|
76
74
|
end
|
75
|
+
|
76
|
+
# BSON Keys cannot contain periods
|
77
|
+
key = path.to_s.tr(".", "_")
|
78
|
+
previous_size = previous_file_names[key]
|
79
|
+
# Check every few minutes for a file size change before trying to process the file.
|
80
|
+
size = check_file(dirmon_entry, path, previous_size)
|
81
|
+
file_names[key] = size if size
|
77
82
|
end
|
78
|
-
|
83
|
+
rescue StandardError => e
|
84
|
+
logger.error("Dirmon Entry: #{dirmon_entry.id} failed. Moved to `failed` state to prevent processing again without manual intervention.", e)
|
85
|
+
dirmon_entry.fail(worker_name, e)
|
86
|
+
dirmon_entry.save(validate: false)
|
79
87
|
end
|
80
88
|
|
81
89
|
# Checks if a file should result in starting a job
|
@@ -145,6 +145,10 @@ module RocketJob
|
|
145
145
|
rescue Exception => e
|
146
146
|
errors.add(field, "Failed to load :#{field}, #{e.inspect}")
|
147
147
|
end
|
148
|
+
|
149
|
+
# Allow multiple instances of this job to run with the same cron schedule
|
150
|
+
def rocket_job_cron_singleton_check
|
151
|
+
end
|
148
152
|
end
|
149
153
|
end
|
150
154
|
end
|
@@ -97,6 +97,10 @@ module RocketJob
|
|
97
97
|
rescue Exception => e
|
98
98
|
errors.add(:code, "Failed to parse :code, #{e.inspect}")
|
99
99
|
end
|
100
|
+
|
101
|
+
# Allow multiple instances of this job to run with the same cron schedule
|
102
|
+
def rocket_job_cron_singleton_check
|
103
|
+
end
|
100
104
|
end
|
101
105
|
end
|
102
106
|
end
|
@@ -13,14 +13,20 @@ module RocketJob
|
|
13
13
|
included do
|
14
14
|
field :dependent_jobs, type: Array, class_attribute: true, user_editable: true, copy_on_restart: true
|
15
15
|
|
16
|
-
define_throttle :
|
17
|
-
define_batch_throttle :
|
16
|
+
define_throttle :dependent_jobs_running?
|
17
|
+
define_batch_throttle :dependent_jobs_running? if respond_to?(:define_batch_throttle)
|
18
|
+
end
|
19
|
+
|
20
|
+
class_methods do
|
21
|
+
def depends_on_job(*jobs)
|
22
|
+
self.dependent_jobs = Array(jobs).collect(&:to_s)
|
23
|
+
end
|
18
24
|
end
|
19
25
|
|
20
26
|
private
|
21
27
|
|
22
28
|
# Checks if there are any dependent jobs are running
|
23
|
-
def
|
29
|
+
def dependent_jobs_running?
|
24
30
|
return false if dependent_jobs.blank?
|
25
31
|
|
26
32
|
jobs_count = RocketJob::Job.running.where(:_type.in => dependent_jobs).count
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module RocketJob
|
2
|
+
module Subscribers
|
3
|
+
# Cause all instances to refresh their in-memory copy
|
4
|
+
# of the Secret Config Registry
|
5
|
+
#
|
6
|
+
# RocketJob::Subscribers::SecretConfig.publish(:refresh)
|
7
|
+
class SecretConfig
|
8
|
+
include RocketJob::Subscriber
|
9
|
+
|
10
|
+
def refresh
|
11
|
+
logger.measure_info "Refreshed Secret Config" do
|
12
|
+
::SecretConfig.refresh!
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -34,6 +34,7 @@ module RocketJob
|
|
34
34
|
logger.info "Rocket Job Server started"
|
35
35
|
|
36
36
|
event_listener = Thread.new { Event.listener }
|
37
|
+
Subscribers::SecretConfig.subscribe if defined?(SecretConfig)
|
37
38
|
Subscribers::Server.subscribe(self) do
|
38
39
|
Subscribers::Worker.subscribe(self) do
|
39
40
|
Subscribers::Logger.subscribe do
|
data/lib/rocket_job/version.rb
CHANGED
data/lib/rocketjob.rb
CHANGED
@@ -83,12 +83,13 @@ module RocketJob
|
|
83
83
|
autoload :UploadFileJob, "rocket_job/jobs/upload_file_job"
|
84
84
|
|
85
85
|
module ReEncrypt
|
86
|
-
autoload :RelationalJob,
|
86
|
+
autoload :RelationalJob, "rocket_job/jobs/re_encrypt/relational_job"
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
90
|
module Subscribers
|
91
91
|
autoload :Logger, "rocket_job/subscribers/logger"
|
92
|
+
autoload :SecretConfig, "rocket_job/subscribers/secret_config"
|
92
93
|
autoload :Server, "rocket_job/subscribers/server"
|
93
94
|
autoload :Worker, "rocket_job/subscribers/worker"
|
94
95
|
end
|
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: 6.
|
4
|
+
version: 6.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Reid Morrison
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aasm
|
@@ -84,14 +84,14 @@ dependencies:
|
|
84
84
|
name: semantic_logger
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '4.7'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '4.7'
|
97
97
|
- !ruby/object:Gem::Dependency
|
@@ -205,6 +205,7 @@ files:
|
|
205
205
|
- lib/rocket_job/sliced/writer/output.rb
|
206
206
|
- lib/rocket_job/subscriber.rb
|
207
207
|
- lib/rocket_job/subscribers/logger.rb
|
208
|
+
- lib/rocket_job/subscribers/secret_config.rb
|
208
209
|
- lib/rocket_job/subscribers/server.rb
|
209
210
|
- lib/rocket_job/subscribers/worker.rb
|
210
211
|
- lib/rocket_job/supervisor.rb
|