fanforce-worker 0.14.2 → 0.14.3

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
- NjA0NGUyMzZiYTU0YzFiMWQ0NTM2NGI3MzI2OTUzOGU1MDg4MDg3OA==
4
+ YjgyZmQ5Y2MzY2M5ODk1ZDQ3YzQ3ODJhMzAzZjhmOGYzNjExZDIyOA==
5
5
  data.tar.gz: !binary |-
6
- OWE0M2FkMDNjZThiNTE3ZmJmNTc2YzQxNGNiNTBjNDhmMTAxYTc2MA==
6
+ NjFkZmQ5ZjFhNzI2YmE5NzUzZGJlYzM3YjE5YTk4Y2FmMzMzNmRlMw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- YzU5OTA0ZmY4ZmIzZGIwYjhmMjM0OGE1ZWQ2NmQ3ZjVkMDExMzNkNTNhNmI2
10
- OTM1YjM1NmFmMGVjMjRjNWZmYTViZDgzZDhkYWM1MjM5NWY0NzE0MjQzYjZh
11
- NzRlNGMyZjY0ZTE0NDE2NzViZWIxZTg0YWQzNDg0ZjVjZDI3MzY=
9
+ M2M3OTliYjg1NThhOWFlMmNlMjVhNzk4MzA0ODA0MWNhZjQwOGI2Nzk5YWFl
10
+ MzdlYjZiYmNjNmZjNTQ4ZmM4YzlmMTc1ZTRiZjliNmYzNjAxZTcwYWY2MmE0
11
+ MDcxMDVkMTAwZDU4NmYxZDQ3Zjc3ZTU4NDZiNWQ3MWQ1YTBjNTI=
12
12
  data.tar.gz: !binary |-
13
- NjdjMWI2ODdlNjdiNzJiOGI0MTk2ZDJhNzczZGE0YWE4ZTg2ZjdmMjA2ZjA4
14
- M2NjMzBjMDY2MzkzZDAxNjAxYzQxYjFiMDFmM2Y5OWQxZGZiMTE5NzkwYmQw
15
- NGU0NDZmODcyZTg0MmUxMWY0NWM2NDBjZWI4ZDA1YzQ2M2I5Yjc=
13
+ OTgxMDM2NWQ2NjcwZTE5ZTdlMjc3NTgzNTY2MzZjYjQyOTYzNjM5ODk2N2E1
14
+ ODM2OWVjNTYzZTY5M2YzMTdjZWVkMmU5YzgxNDQ1ZThmNTY3MWNjMjU1Y2Jj
15
+ ZTA1NzQ3NjUxOTEzMTM0NDI1YTc1ZWU5N2JmYmRlNDBlNWIwZTc=
@@ -1,5 +1,5 @@
1
1
  class Fanforce
2
2
  class Worker
3
- VERSION = '0.14.2'
3
+ VERSION = '0.14.3'
4
4
  end
5
5
  end
@@ -1,6 +1,6 @@
1
1
  class Fanforce::Worker
2
2
 
3
- LOAD_TIME = Time.now
3
+ LOADED_AT = Time.now
4
4
  MAX_EXECUTION_TIME = 3300
5
5
 
6
6
  def initialize(opts={})
@@ -161,9 +161,9 @@ class Fanforce::Worker
161
161
  puts 'PROCESSING...'
162
162
  job_num = 0
163
163
  job_data = nil
164
- while has_enough_time_to_run(min_execution_time) and (job = queue.get(timeout: 3600)) do
164
+ while job_has_enough_time_to_run(min_execution_time) and (job = queue.get(timeout: 3600)) do
165
165
  puts "- JOB #{job_num+=1}: #{job.body}"
166
- timeout(time_remaining) do
166
+ timeout(worker_time_remaining) do
167
167
  job_data = nil
168
168
  job_data = Fanforce.decode_json(job.body)
169
169
  run_job(job, job_data, &code_block)
@@ -178,15 +178,15 @@ class Fanforce::Worker
178
178
  handle_job_loading_error(e, job, job_data)
179
179
  end
180
180
 
181
- def time_remaining
182
- time_running = Time.now - LOAD_TIME
183
- MAX_EXECUTION_TIME - time_running
181
+ def self.worker_time_remaining
182
+ time_since_load = Time.now - LOADED_AT
183
+ MAX_EXECUTION_TIME - time_since_load
184
184
  end
185
185
 
186
- def has_enough_time_to_run(min_execution_time)
187
- time_running = Time.now - LOAD_TIME
188
- return false if time_running < MAX_EXECUTION_TIME
189
- return false if time_remaining < min_execution_time
186
+ def self.job_has_enough_time_to_run(min_execution_time)
187
+ time_since_load = Time.now - LOADED_AT
188
+ return false if time_since_load < MAX_EXECUTION_TIME
189
+ return false if worker_time_remaining < min_execution_time
190
190
  return true
191
191
  end
192
192
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fanforce-worker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.2
4
+ version: 0.14.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Caleb Clark