fanforce-workers 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NGZlZmM5MTQ0N2M3Yjc4ZWQ4NjZkOWU0MDA3OGJjYmVjOWNlMjliNg==
4
+ N2YxMGU0OTJmNjZlNTU1MDBhNTk2Y2MzMTMxYTliNzZhODM2NzU4MA==
5
5
  data.tar.gz: !binary |-
6
- NGNlY2NlZDVmYTNiZjAzODhhZjVjZjNhMzkzZDg5YWMyZWUzOTM1Yg==
6
+ Yzc0MDJlMDQ4MDIzYzc4YmVhZGQyNjY5NTkzZjE2NGZkYzZmNDMyNA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- M2ZlMDc0NDYxNGVkZGUwNjcwMTg3MzdkNjc4MmUzZmQ2MzVkZGJjODc0ZmQ2
10
- Y2ZkZjZiMzY2MmUxMThhMjgyNGYwNzc5NjJhNzI1NTU0NDdiNWFjNmU3MmVj
11
- YWZkYTBhZDlhYzk0YWJiM2Y0OWNhZGFiYmM4ZTgzY2E5ZTk4ZDI=
9
+ YmEwY2Y5ZjAxMzMwYmQ2NTM0MjdjMGQwM2EyZGJjYWZjODViOGFjNjQxMGUy
10
+ ZjNlN2ZhZmIyNDEzNDU4OTM5ZDU2ODU1MTFkNzFmOTlhYjJiOWYxYmJhYmY4
11
+ OWVlOGRjMGU5NTk2ZTg0MDEzOTdkZDdhNzdjY2Y4MmU1OWZiNDA=
12
12
  data.tar.gz: !binary |-
13
- ODkxYjE5MmFiZjNhYWJjNTg5ODZkOGY1YWY4NDUxZjM1YTE3MWUxODhjMGYy
14
- YzViNzE1ZjcxNzU0ZWQ0NDNmMjJjNDhjOTA4MjhjODc0NDA3OWY3ZWI1M2I4
15
- M2YxZTNkMWY5MjVkOWNjMWY3YjMzZTBiMGZmMDcyOTlkZjZkMDk=
13
+ ZDY2MzkzNGYxODMzNDA4Zjc0NjMzZDFjODY0NWE3YzI1ZGVmZjNkZGQwZTAz
14
+ OTkwMjYwYmY3OTYwZWQ3NTgzOGQ0YTUzYTFiMTg2MWQ0ZGEzN2MxNGY5MjM0
15
+ MDk1ZWNiODM0ZTg4OTBiMGI5YmQxNmZhYWZjYTg1ZThmZGRlMTA=
@@ -5,9 +5,6 @@ class Fanforce::Workers::Iron
5
5
  end
6
6
 
7
7
  def queue(queue_id, payload)
8
- raise 'Payload being sent to the queue must be a Hash' if !payload.is_a?(Hash)
9
- payload = {params: payload, retries: 0}
10
-
11
8
  @iron_mq.queue(queue_id).post(payload.to_json)
12
9
  end
13
10
 
@@ -1,5 +1,5 @@
1
1
  class Fanforce
2
2
  module Workers
3
- VERSION = '0.3.0'
3
+ VERSION = '0.3.1'
4
4
  end
5
5
  end
@@ -15,7 +15,6 @@ class Fanforce::Worker
15
15
  (msg.nil?) ? (return) : run_worker(msg)
16
16
  end
17
17
 
18
-
19
18
  def require_dependencies
20
19
  require '.pluginenv'
21
20
  require 'fanforce/api'
@@ -31,24 +30,26 @@ class Fanforce::Worker
31
30
  end
32
31
 
33
32
  def run_worker(msg)
33
+ print 'PROCESSING MESSAGE: '
34
34
  puts msg.body
35
- puts '-------------------------------------------'
36
35
  task_data = Fanforce.decode_json(msg.body)
37
- puts task_data.to_json
38
36
 
39
37
  set_env_vars(@worker_data['env_vars'])
40
-
41
38
  @code_block.call(task_data[:params].clone, task_data[:retries].clone)
42
39
  msg.delete
43
- rescue => e
40
+
41
+ rescue Exception => e
44
42
  task_data[:last_error] = {
45
43
  exception: e.class.name,
46
44
  message: e.message,
47
45
  backtrace: e.backtrace,
48
46
  raised_at: Time.now
49
47
  }
48
+ task_data[:env_vars] = @worker_data['env_vars']
49
+ print 'ADDING TO ERROR QUEUE: '
50
+ puts task_data.to_json
50
51
  Fanforce::Workers.iron.queue "#{@worker_data['worker_id']}-ERRORS", task_data
51
- msg.delete
52
+ puts 'DELETED MESSAGE'
52
53
  end
53
54
 
54
55
  def set_env_vars(vars)
@@ -9,4 +9,9 @@ module Fanforce::Workers
9
9
  @iron ||= Fanforce::Workers::Iron.new(opts)
10
10
  end
11
11
 
12
+ def queue_task(queue_id, payload)
13
+ raise 'Payload being sent to the queue must be a Hash' if !payload.is_a?(Hash)
14
+ iron.queue queue_id, params: payload, retries: 0
15
+ end
16
+
12
17
  end
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.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Caleb Clark