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 +8 -8
- data/lib/fanforce/workers/iron.rb +0 -3
- data/lib/fanforce/workers/version.rb +1 -1
- data/lib/fanforce/workers/worker.rb +7 -6
- data/lib/fanforce/workers/workers.rb +5 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
N2YxMGU0OTJmNjZlNTU1MDBhNTk2Y2MzMTMxYTliNzZhODM2NzU4MA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
Yzc0MDJlMDQ4MDIzYzc4YmVhZGQyNjY5NTkzZjE2NGZkYzZmNDMyNA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YmEwY2Y5ZjAxMzMwYmQ2NTM0MjdjMGQwM2EyZGJjYWZjODViOGFjNjQxMGUy
|
10
|
+
ZjNlN2ZhZmIyNDEzNDU4OTM5ZDU2ODU1MTFkNzFmOTlhYjJiOWYxYmJhYmY4
|
11
|
+
OWVlOGRjMGU5NTk2ZTg0MDEzOTdkZDdhNzdjY2Y4MmU1OWZiNDA=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZDY2MzkzNGYxODMzNDA4Zjc0NjMzZDFjODY0NWE3YzI1ZGVmZjNkZGQwZTAz
|
14
|
+
OTkwMjYwYmY3OTYwZWQ3NTgzOGQ0YTUzYTFiMTg2MWQ0ZGEzN2MxNGY5MjM0
|
15
|
+
MDk1ZWNiODM0ZTg4OTBiMGI5YmQxNmZhYWZjYTg1ZThmZGRlMTA=
|
@@ -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
|
-
|
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
|
-
|
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
|