rocketjob 2.0.0.rc2 → 2.0.0.rc3
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 272892209b4b987a90ec99fe808e7197588c1fea
|
4
|
+
data.tar.gz: 560ead0b08ab42a2fc6cda4de2f3ed107199fce7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7c162229dfaed223d3346f6a31613026fd8dff5dcbd590e11b9b4569e98b65ed9fa31850db395248d54be9005017cf7bb28c12517a559a38e84f44b90146656
|
7
|
+
data.tar.gz: 0614a2ccfdcece55f6480d880eef065e8034629695f7678e21bc6212231351c24ebf1cab06e53553f7102479554eca419eadd208a4716b7a83a53e25ab56bc46
|
@@ -305,10 +305,12 @@ module RocketJob
|
|
305
305
|
# Queues the job for the supplied pathname
|
306
306
|
def later(pathname)
|
307
307
|
if klass = job_class
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
308
|
+
logger.benchmark_info "Enqueued: #{name}, Job class: #{job_class_name}" do
|
309
|
+
job = klass.new(properties.merge(arguments: arguments))
|
310
|
+
upload_file(job, pathname)
|
311
|
+
job.save!
|
312
|
+
job
|
313
|
+
end
|
312
314
|
else
|
313
315
|
raise(ArgumentError, "Cannot instantiate a class for: #{job_class_name.inspect}")
|
314
316
|
end
|
@@ -6,17 +6,20 @@ require 'mongo_mapper'
|
|
6
6
|
|
7
7
|
module RocketJob
|
8
8
|
module Plugins
|
9
|
-
#
|
9
|
+
# Base class for storing models in MongoDB
|
10
10
|
module Document
|
11
|
+
autoload :Static, 'rocket_job/plugins/document/static'
|
12
|
+
|
11
13
|
extend ActiveSupport::Concern
|
12
14
|
include MongoMapper::Document
|
15
|
+
include RocketJob::Plugins::Document::Static
|
13
16
|
|
14
17
|
included do
|
15
18
|
# Add after_initialize & after_find callbacks
|
16
19
|
define_model_callbacks :initialize, :find, :only => [:after]
|
17
20
|
|
18
21
|
# Prevent data in MongoDB from re-defining the model behavior
|
19
|
-
|
22
|
+
self.static_keys = true
|
20
23
|
|
21
24
|
# Turn off embedded callbacks. Slow and not used for Jobs
|
22
25
|
embedded_callbacks_off
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module RocketJob
|
2
|
+
module Plugins
|
3
|
+
# Extension for Document to implement static keys
|
4
|
+
# Remove when new MongoMapper gem is released
|
5
|
+
module Document
|
6
|
+
module Static
|
7
|
+
extend ActiveSupport::Concern
|
8
|
+
|
9
|
+
module ClassMethods
|
10
|
+
attr_writer :static_keys
|
11
|
+
|
12
|
+
def static_keys
|
13
|
+
@static_keys || false
|
14
|
+
end
|
15
|
+
|
16
|
+
def embedded_keys
|
17
|
+
@embedded_keys ||= embedded_associations.collect(&:as)
|
18
|
+
end
|
19
|
+
|
20
|
+
def embedded_key?(key)
|
21
|
+
embedded_keys.include?(key.to_sym)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def read_key(name)
|
26
|
+
if !self.class.static_keys || self.class.key?(name)
|
27
|
+
super
|
28
|
+
else
|
29
|
+
raise MissingKeyError, "Tried to read the key #{name.inspect}, but no key was defined. Either define key :#{name} or set self.static_keys = false"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def write_key(name, value)
|
36
|
+
if !self.class.static_keys || self.class.key?(name)
|
37
|
+
super
|
38
|
+
else
|
39
|
+
raise MissingKeyError, "Tried to write the key #{name.inspect}, but no key was defined. Either define key :#{name} or set self.static_keys = false"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def load_from_database(attrs, with_cast = false)
|
44
|
+
return super if !self.class.static_keys || !attrs.respond_to?(:each)
|
45
|
+
|
46
|
+
attrs = attrs.select { |key, _| self.class.key?(key) || self.class.embedded_key?(key) }
|
47
|
+
|
48
|
+
super(attrs, with_cast)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -187,6 +187,7 @@ module RocketJob
|
|
187
187
|
|
188
188
|
# Add to user definable properties in Dirmon Entry
|
189
189
|
def self.public_rocket_job_properties(*properties)
|
190
|
+
properties.each { |property| raise("Invalid public_rocket_job_property: #{property.inspect}") unless key?(property)}
|
190
191
|
rocket_job_properties.concat(properties).uniq!
|
191
192
|
end
|
192
193
|
|
@@ -237,6 +238,7 @@ module RocketJob
|
|
237
238
|
def as_json
|
238
239
|
attrs = serializable_hash(methods: [:seconds, :duration])
|
239
240
|
attrs.delete('result') unless collect_output?
|
241
|
+
attrs.delete('failure_count') unless failure_count > 0
|
240
242
|
case
|
241
243
|
when queued?
|
242
244
|
attrs.delete('started_at')
|
@@ -247,6 +249,9 @@ module RocketJob
|
|
247
249
|
attrs.delete('completed_at')
|
248
250
|
attrs.delete('result')
|
249
251
|
attrs
|
252
|
+
when completed?
|
253
|
+
attrs.delete('percent_complete')
|
254
|
+
attrs
|
250
255
|
when paused?
|
251
256
|
attrs.delete('completed_at')
|
252
257
|
attrs.delete('result')
|
@@ -269,8 +274,6 @@ module RocketJob
|
|
269
274
|
def status(time_zone = 'Eastern Time (US & Canada)')
|
270
275
|
h = as_json
|
271
276
|
h.delete('seconds')
|
272
|
-
h.delete('percent_complete') if completed?
|
273
|
-
h.delete('failure_count') unless failure_count > 0
|
274
277
|
h.dup.each_pair do |k, v|
|
275
278
|
case
|
276
279
|
when v.is_a?(Time)
|
data/lib/rocket_job/version.rb
CHANGED
data/lib/rocket_job/worker.rb
CHANGED
@@ -45,7 +45,7 @@ module RocketJob
|
|
45
45
|
key :started_at, Time
|
46
46
|
|
47
47
|
# The heartbeat information for this worker
|
48
|
-
|
48
|
+
has_one :heartbeat, class_name: 'RocketJob::Heartbeat'
|
49
49
|
|
50
50
|
# Current state
|
51
51
|
# Internal use only. Do not set this field directly
|
@@ -196,7 +196,7 @@ module RocketJob
|
|
196
196
|
# - The worker is no longer able to communicate with the MongoDB Server
|
197
197
|
def zombie?(missed = 4)
|
198
198
|
return false unless running?
|
199
|
-
return true if heartbeat.updated_at.nil?
|
199
|
+
return true if heartbeat.nil? || heartbeat.updated_at.nil?
|
200
200
|
dead_seconds = Config.instance.heartbeat_seconds * missed
|
201
201
|
(Time.now - heartbeat.updated_at) >= dead_seconds
|
202
202
|
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: 2.0.0.
|
4
|
+
version: 2.0.0.rc3
|
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-02-
|
11
|
+
date: 2016-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aasm
|
@@ -134,6 +134,7 @@ files:
|
|
134
134
|
- lib/rocket_job/jobs/dirmon_job.rb
|
135
135
|
- lib/rocket_job/jobs/simple_job.rb
|
136
136
|
- lib/rocket_job/plugins/document.rb
|
137
|
+
- lib/rocket_job/plugins/document/static.rb
|
137
138
|
- lib/rocket_job/plugins/job/callbacks.rb
|
138
139
|
- lib/rocket_job/plugins/job/defaults.rb
|
139
140
|
- lib/rocket_job/plugins/job/logger.rb
|