rocketjob 3.0.0 → 3.0.1

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: 665d894a78de154892a8c53e03f2a2a81f6230f9
4
- data.tar.gz: d89dba90f39ef98f7205366b166a45d928fb84db
3
+ metadata.gz: a8f3f4b74a0c8fc21434e841b045e285474d2508
4
+ data.tar.gz: 9b1a0c551b00e0470f7f0cf524d0b24c493df900
5
5
  SHA512:
6
- metadata.gz: c275f0ca475518de2acddce890b924312e8e40e5f04f74e2f4c8a235235723c5b1d3a322d0c10dd29d512f3d2f492b6c52d917b8a491185a18a61634ecfde174
7
- data.tar.gz: 6f368bdd55d728530252d30d16a34b0b215caaa4cbe1a199b3aa1d369a48044cbd90642e2bec55fa039238897401a5223f67c56bbe7d02d98adea63e44f2b09e
6
+ metadata.gz: 36c29026484cb8f60930318609c94c31044231bb43c53cac55185f89b6479e5446a53522e49bac5bad86506988338fdca48b8f67b2094209b93a144c355d1ff8
7
+ data.tar.gz: 333637778b2cd085e5ea58b1852e57626859e8499918cfd48af4e2dfac893792c5f9619b42070ec0303209ef9287f9e50d281060a92f4e07bcd2461b434e3c6c
@@ -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
- load path.expand_path.to_s
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
- # TODO Somehow get AASM to support options such as :if and :unless to be consistent with other callbacks
46
- # For example:
47
- # before_start :my_callback, unless: :encrypted?
48
- # before_start :my_callback, if: :encrypted?
49
- if event = aasm.state_machine.events[event_name]
50
- values = Array(event.options[action])
51
- code =
52
- if block
53
- block
54
- else
55
- # Validate methods are any of Symbol String Proc
56
- methods.each do |method|
57
- unless method.is_a?(Symbol) || method.is_a?(String)
58
- raise(ArgumentError, "#{action}_#{event_name} currently does not support any options. Only Symbol and String method names can be supplied.")
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
- methods
62
- end
63
- action == :before ? values.push(code) : values.unshift(code)
64
- event.options[action] = values.flatten.uniq
65
- else
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
 
@@ -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
 
@@ -1,4 +1,4 @@
1
1
  # encoding: UTF-8
2
2
  module RocketJob #:nodoc
3
- VERSION = '3.0.0'
3
+ VERSION = '3.0.1'
4
4
  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: 3.0.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-01-25 00:00:00.000000000 Z
11
+ date: 2017-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby