fanforce-plugin-worker 2.0.0.rc11 → 2.0.0.rc12

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: 83a44c80d188889bc6624e719bb97ec7a1bbbf0b
4
- data.tar.gz: 399f51d4a1d285addae3de4471ad2ca85f5394e0
3
+ metadata.gz: e756e918d0ff2a7dc9070491506c6e61042f56f5
4
+ data.tar.gz: 5c88d554a6bf80df472c8af395665fe96f645d38
5
5
  SHA512:
6
- metadata.gz: 8c2ce08084ebba9183f5572e6151b4e8b9dd764bcfef7c035b3835af001e1f2963d83123b483213dfabc356a111245870f57e97c92935b8344ef2d6e30519b61
7
- data.tar.gz: 5e3b914eaf0ba4a145d990f800a43111835911ec436db3fb4f55d079ddc75c5d7add3a12fa245fdedf104516d50f593771b99d251f0bf181b1962d19fbb8a7f0
6
+ metadata.gz: e59fab71af38e7301e2e890948f5dae785949464c3896ab2973283e2a7e745a0c5c03981283657a0832f1c67d2e4319c10213fd0541585c5276cc2b65227044d
7
+ data.tar.gz: 8d377a77dd2eebcd53477a974ebdde7aa13893fd4334aa3fb86c48a9882a33eab93f30e74b93bf93ba89e3061977c866f70fb06ee574a584616431cc24c8f293
@@ -24,7 +24,6 @@ Gem::Specification.new do |gem|
24
24
  gem.add_runtime_dependency 'uuid', '~> 2.3.7'
25
25
  gem.add_runtime_dependency 'activesupport', '~> 4.1.6'
26
26
  gem.add_runtime_dependency 'redis', '~> 3.1.0'
27
- gem.add_runtime_dependency 'multi_json', '>= 1.7.2'
28
27
 
29
28
  gem.add_runtime_dependency 'rest_client', '= 1.7.3'
30
29
 
@@ -19,6 +19,7 @@ if ENV['PWD'] == '/mnt/task'
19
19
 
20
20
  Plugin = Fanforce::Plugin
21
21
  PluginWorker = Fanforce::PluginWorker
22
+ PluginWorker.is_iron_worker(true)
22
23
 
23
24
  # When running in Docker, IronWorker no longer provides the params method
24
25
  def params; IronWorker.payload end
@@ -1,5 +1,5 @@
1
1
  class Fanforce
2
2
  class PluginWorker
3
- VERSION = '2.0.0.rc11'
3
+ VERSION = '2.0.0.rc12'
4
4
  end
5
5
  end
@@ -7,6 +7,15 @@ class Fanforce::PluginWorker
7
7
  @@log = Logger.new($stdout)
8
8
  @@log.datetime_format = '%H:%M:%S'
9
9
  @@log.formatter = proc do |severity, datetime, prog_name, msg| "#{datetime}: #{msg}\n" end
10
+ @@is_iron_worker = false
11
+
12
+ def self.is_iron_worker(bool)
13
+ @@is_iron_worker = bool
14
+ end
15
+
16
+ def self.is_iron_worker?
17
+ @@is_iron_worker
18
+ end
10
19
 
11
20
  def self.iron_token
12
21
  @@iron[:token] || ENV['IRON_TOKEN']
@@ -40,8 +49,8 @@ class Fanforce::PluginWorker
40
49
  def self.enqueue(queue_id, params, options={})
41
50
  raise 'Params being sent to the queue must be a Hash' if !params.is_a?(Hash)
42
51
 
43
- if [true,'true'].include?(ENV['FANFORCE_WORKER_SHOULD_BYPASS_ENQUEUE'])
44
- bypass_enqueue(queue_id, params)
52
+ if [true,'true'].include?(ENV['FANFORCE_WORKER_SHOULD_RUN_LOCALLY_AND_INSTANTLY']) and !is_iron_worker?
53
+ run_locally_and_instantly(queue_id, params)
45
54
  else
46
55
  queue_id = Utils.iron_queue_id(queue_id)
47
56
  retries = (options[:retries].present?) ? options.delete(:retries) : 0
@@ -49,7 +58,7 @@ class Fanforce::PluginWorker
49
58
  end
50
59
  end
51
60
 
52
- def self.bypass_enqueue(queue_id, params)
61
+ def self.run_locally_and_instantly(queue_id, params)
53
62
  exec_file = "#{Plugin.base_dir}/workers/#{queue_id}.rb"
54
63
  raise "Ruby file is missing: #{exec_file}" if !File.exists?(exec_file)
55
64
  raise "RACK_ENV must be development: #{ENV['RACK_ENV']}" if ENV['RACK_ENV'] != 'development'
@@ -58,7 +67,7 @@ class Fanforce::PluginWorker
58
67
  end
59
68
 
60
69
  def self.run(worker_data, min_execution_time=300, &code_block)
61
- if [true,'true'].include?(ENV['FANFORCE_WORKER_SHOULD_BYPASS_ENQUEUE'])
70
+ if [true,'true'].include?(ENV['FANFORCE_WORKER_SHOULD_RUN_LOCALLY_AND_INSTANTLY']) and !is_iron_worker?
62
71
  RunnerLocal.new(worker_data, min_execution_time).run_job(&code_block)
63
72
  else
64
73
  Runner.new(worker_data, min_execution_time, &code_block)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fanforce-plugin-worker
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.rc11
4
+ version: 2.0.0.rc12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Caleb Clark
@@ -108,20 +108,6 @@ dependencies:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: 3.1.0
111
- - !ruby/object:Gem::Dependency
112
- name: multi_json
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- version: 1.7.2
118
- type: :runtime
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- version: 1.7.2
125
111
  - !ruby/object:Gem::Dependency
126
112
  name: rest_client
127
113
  requirement: !ruby/object:Gem::Requirement