fanforce-workers 0.7.5 → 0.7.6

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZTJkNTljODQ3MzYzY2ZlNGJlODQzZGQ4NmU3MWI0YmNlMGM2MWIyMw==
4
+ ZTIwODQwZjBlODIxMTMzYmFlNzYzZWY0YzIxMTEzZWRlYjRkYWRmNg==
5
5
  data.tar.gz: !binary |-
6
- ZWRlMGFiMjQ4MDBhMjVlYTUzMWIyM2UyYjE3MjliZWIzYTI4ZTk2ZA==
6
+ MDlhMDMyY2Q4YWMzYzgwMmQyYjFiOWFjODBmZWFlYTI2MmYxOWRiMA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- MzY1ZjlkOTE3YzRjYWE1MzY3MDc0ODc1MGNhY2ZiMjUyYTQ0MjJmNTMxMDg3
10
- Y2ZkYTQ3OGQyNGMyODA5MWJjY2NmNTIyODc0MDI0MmFkYjQ5ZDRjZjg5MzQ4
11
- ZTM4OWZjNzM1NDE4MGQ1MDkwN2U4MTIxZjMzNWRjYzZlMGMyMzE=
9
+ MzIwZmMzMzYyOGVjMWY2NDNjOThjN2NmODk0Mzc5YjEwNjRkZDM4MDkzY2Q4
10
+ MDVmZmYyMDAwZGYyYmUwZTIyYTQzNjA4YTFiODcwYThhNGNkZmRjN2RhNDkz
11
+ NzYzOGZlN2QwZTY1MzJkOTBiNGZlMmJhMGYxMjgwMTdiNTEwYTg=
12
12
  data.tar.gz: !binary |-
13
- NTY5YmNiZTI4ZTdiYTlhM2Q1YjYwNzY0MWY0MzYxNWM1MjBlYzAxNzg2MWY4
14
- MjliZWU4MDg1NDVhYThhNzJkZmM1OWM2NjFiNDRkNThjZDkxMjAyZDMxYjQw
15
- MmU4MGM1ZThjYTNhNGNiYmU2ZjQ4NDJmNThhOTllYTM3NzQ3NjM=
13
+ NGMxODhiMTRkNDllOTFkZTg5MTYxZWE5NWEwNTQ3NzZiYWY4M2M3YmZkM2E1
14
+ ZDkxNTdkZTQ5YTRmZDU2ZmM4YjVjNzg0ZTUxNmRlMTAwMzlhYmNhYTZlMmRi
15
+ YWI4NmZmZWJhZGYyYWQ4MTViNTlkMDRjNDU4Zjc1MmI1N2ViOTA=
@@ -1,5 +1,5 @@
1
1
  class Fanforce
2
2
  class Workers
3
- VERSION = '0.7.5'
3
+ VERSION = '0.7.6'
4
4
  end
5
5
  end
@@ -106,6 +106,14 @@ class Fanforce::Workers
106
106
  @current_retries
107
107
  end
108
108
 
109
+ def self.current_job=(job)
110
+ @current_job = job
111
+ end
112
+
113
+ def self.current_job
114
+ @current_job
115
+ end
116
+
109
117
  def self.run(worker_data, &code_block)
110
118
  require '.pluginenv'
111
119
  require 'iron_mq'
@@ -122,7 +130,9 @@ class Fanforce::Workers
122
130
  while (job = queue.get(timeout: 3600)) do
123
131
  puts "JOB #{job_num+=1}: #{job.body}"
124
132
  run_job job, &code_block
133
+ self.delete_job
125
134
  end
135
+ self.delete_job
126
136
  puts 'DONE'
127
137
  end
128
138
 
@@ -135,12 +145,13 @@ class Fanforce::Workers
135
145
  print 'PROCESSING MESSAGE: '
136
146
 
137
147
  task_data = Fanforce.decode_json(job.body)
148
+ self.current_job = job
138
149
  self.current_params = task_data[:params]
139
150
  self.current_retries = task_data[:retries]
140
151
 
141
152
  set_env_vars(current_worker_env)
142
153
  code_block.call(task_data[:params].clone, retries: task_data[:retries], queue_id: current_queue_id)
143
- job.delete
154
+ self.delete_job(job)
144
155
 
145
156
  rescue Exception => e
146
157
  if job.nil?
@@ -157,12 +168,18 @@ class Fanforce::Workers
157
168
  error[:curl_command] = e.curl_command if e.respond_to?(:curl_command)
158
169
 
159
170
  puts "ADDING TO ERROR CACHE: #{error.to_json}"
160
- job.delete
171
+ self.delete_job(job)
161
172
  puts 'DELETED MESSAGE'
162
173
 
163
174
  self.add_error current_queue_id, error
164
175
  end
165
176
 
177
+ def self.delete_job(job=nil)
178
+ return if job.nil? and current_job.nil?
179
+ (job || current_job).delete
180
+ self.current_job = nil
181
+ end
182
+
166
183
  def self.set_env_vars(vars)
167
184
  vars.each {|k,v| ENV[k.to_s]=v }
168
185
  load 'fanforce/api/ff_globals.rb'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fanforce-workers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.5
4
+ version: 0.7.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Caleb Clark