rocketjob 3.0.0 → 3.0.1
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/cli.rb +3 -1
- data/lib/rocket_job/plugins/state_machine.rb +24 -20
- data/lib/rocket_job/server.rb +1 -1
- data/lib/rocket_job/version.rb +1 -1
- 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: a8f3f4b74a0c8fc21434e841b045e285474d2508
|
4
|
+
data.tar.gz: 9b1a0c551b00e0470f7f0cf524d0b24c493df900
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36c29026484cb8f60930318609c94c31044231bb43c53cac55185f89b6479e5446a53522e49bac5bad86506988338fdca48b8f67b2094209b93a144c355d1ff8
|
7
|
+
data.tar.gz: 333637778b2cd085e5ea58b1852e57626859e8499918cfd48af4e2dfac893792c5f9619b42070ec0303209ef9287f9e50d281060a92f4e07bcd2461b434e3c6c
|
data/lib/rocket_job/cli.rb
CHANGED
@@ -70,6 +70,7 @@ module RocketJob
|
|
70
70
|
logger.measure_info('Eager loaded Rails and all Engines') do
|
71
71
|
Rails.application.eager_load!
|
72
72
|
Rails::Engine.subclasses.each(&:eager_load!)
|
73
|
+
self.class.eager_load_jobs(File.expand_path('jobs', File.dirname(__FILE__)))
|
73
74
|
end
|
74
75
|
end
|
75
76
|
end
|
@@ -96,6 +97,7 @@ module RocketJob
|
|
96
97
|
|
97
98
|
logger.info "Rails not detected. Running standalone: #{environment}"
|
98
99
|
RocketJob::Config.load!(environment, mongo_config, symmetric_encryption_config)
|
100
|
+
self.class.eager_load_jobs(File.expand_path('jobs', File.dirname(__FILE__)))
|
99
101
|
self.class.eager_load_jobs
|
100
102
|
end
|
101
103
|
|
@@ -136,7 +138,7 @@ module RocketJob
|
|
136
138
|
Pathname.glob("#{path}/**/*.rb").each do |path|
|
137
139
|
next if path.directory?
|
138
140
|
logger.debug "Loading #{path.to_s}"
|
139
|
-
|
141
|
+
require path.expand_path.to_s
|
140
142
|
end
|
141
143
|
end
|
142
144
|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# encoding: UTF-8
|
2
|
+
require 'thread'
|
2
3
|
require 'active_support/concern'
|
3
4
|
require 'aasm'
|
4
5
|
require 'rocket_job/extensions/aasm'
|
@@ -28,6 +29,7 @@ module RocketJob
|
|
28
29
|
# end
|
29
30
|
module StateMachine
|
30
31
|
extend ActiveSupport::Concern
|
32
|
+
@@aasm_mutex = Mutex.new
|
31
33
|
|
32
34
|
included do
|
33
35
|
include AASM
|
@@ -42,28 +44,30 @@ module RocketJob
|
|
42
44
|
raise(ArgumentError, 'Cannot supply both a method name and a block') if (methods.size > 0) && block
|
43
45
|
raise(ArgumentError, 'Must supply either a method name or a block') unless (methods.size > 0) || block
|
44
46
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
block
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
47
|
+
@@aasm_mutex.synchronize do
|
48
|
+
# TODO Somehow get AASM to support options such as :if and :unless to be consistent with other callbacks
|
49
|
+
# For example:
|
50
|
+
# before_start :my_callback, unless: :encrypted?
|
51
|
+
# before_start :my_callback, if: :encrypted?
|
52
|
+
if event = aasm.state_machine.events[event_name]
|
53
|
+
values = Array(event.options[action])
|
54
|
+
code =
|
55
|
+
if block
|
56
|
+
block
|
57
|
+
else
|
58
|
+
# Validate methods are any of Symbol String Proc
|
59
|
+
methods.each do |method|
|
60
|
+
unless method.is_a?(Symbol) || method.is_a?(String)
|
61
|
+
raise(ArgumentError, "#{action}_#{event_name} currently does not support any options. Only Symbol and String method names can be supplied.")
|
62
|
+
end
|
59
63
|
end
|
64
|
+
methods
|
60
65
|
end
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
raise(ArgumentError, "Unknown event: #{event_name.inspect}")
|
66
|
+
action == :before ? values.push(code) : values.unshift(code)
|
67
|
+
event.options[action] = values.flatten.uniq
|
68
|
+
else
|
69
|
+
raise(ArgumentError, "Unknown event: #{event_name.inspect}")
|
70
|
+
end
|
67
71
|
end
|
68
72
|
end
|
69
73
|
|
data/lib/rocket_job/server.rb
CHANGED
@@ -271,7 +271,7 @@ module RocketJob
|
|
271
271
|
ensure
|
272
272
|
# Logs the backtrace for each running worker
|
273
273
|
if SemanticLogger::VERSION.to_i >= 4
|
274
|
-
workers.each { |worker| logger.backtrace(thread: worker.thread) }
|
274
|
+
workers.each { |worker| logger.backtrace(thread: worker.thread) if worker.thread && worker.alive? }
|
275
275
|
end
|
276
276
|
end
|
277
277
|
|
data/lib/rocket_job/version.rb
CHANGED
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: 3.0.
|
4
|
+
version: 3.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Reid Morrison
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|