fanforce-workers 0.3.5 → 0.4.0
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 +8 -8
- data/lib/fanforce/workers/iron.rb +5 -1
- data/lib/fanforce/workers/version.rb +1 -1
- data/lib/fanforce/workers/workers.rb +19 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YWJjZTQzZjRkYWY0NTBkYTU1NTIyZmRlYzNkMGEyMWZjYjVjMThlMQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MzQzZDlkOTlhYjI1ZDg0ZGMzNGNlY2QyOGU1NTc3NTk0Y2M3ODYwYw==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NWFkYzE2MzliZjhmNWU3MjFjZjUyMGMyNjEwMmQzNmI4YWIyZDJjM2RiYTg1
|
10
|
+
YmVhZGZmYTJkOTBjMDZiZGIyMGI4N2UzZjM3MWJmYzUzZjk0YTgxZDNjNmYz
|
11
|
+
NWY2ZjRiYTcyNmVhODcxYjQxNjY4MmI2ZTUxNTk2YzJlMWJkMDE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OGFiNjRmZjI0MDFlMjU2ODg5YTYwODk3YWEwZWIzNjlkMjA1NDRiY2I0Mzcx
|
14
|
+
NWNkMTgzOTcwNjdlNGYzNGI0MTViYTZiYTVmMjJlZDNhMmFlYTkxNzczNWYy
|
15
|
+
NTBhMDVlYjQ0OTlmOWFkMTExZWE5OTg2MDFjMDM0N2Q2YmMxNjQ=
|
@@ -4,8 +4,12 @@ class Fanforce::Workers::Iron
|
|
4
4
|
@iron_mq = IronMQ::Client.new(:token => opts[:token] || ENV['IRON_TOKEN'], :project_id => opts[:project_id] || ENV['IRON_PROJECT_ID'])
|
5
5
|
end
|
6
6
|
|
7
|
-
def
|
7
|
+
def enqueue(queue_id, payload)
|
8
8
|
@iron_mq.queue(queue_id).post(payload.to_json)
|
9
9
|
end
|
10
10
|
|
11
|
+
def client
|
12
|
+
@iron_qa
|
13
|
+
end
|
14
|
+
|
11
15
|
end
|
@@ -1,17 +1,29 @@
|
|
1
1
|
require 'iron_mq'
|
2
2
|
|
3
|
-
|
4
|
-
extend Fanforce::Workers
|
5
|
-
def self.included(base) base.extend(self) end
|
3
|
+
class Fanforce::Workers
|
6
4
|
|
7
|
-
def
|
5
|
+
def initialize(opts={})
|
6
|
+
@opts = opts
|
7
|
+
end
|
8
|
+
|
9
|
+
def iron
|
8
10
|
require_relative 'iron'
|
9
|
-
@iron ||= Fanforce::Workers::Iron.new(opts)
|
11
|
+
@iron ||= Fanforce::Workers::Iron.new(@opts)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.enqueue(queue_id, payload)
|
15
|
+
self.new.enqueue(queue_id, payload)
|
10
16
|
end
|
11
17
|
|
12
|
-
def
|
18
|
+
def enqueue(queue_id, payload)
|
13
19
|
raise 'Payload being sent to the queue must be a Hash' if !payload.is_a?(Hash)
|
14
|
-
iron.
|
20
|
+
iron.enqueue queue_id, params: payload, retries: 0
|
21
|
+
end
|
22
|
+
|
23
|
+
def retry_error(queue_id, msg_id)
|
24
|
+
msg = iron.client.queue(queue_id + '-ERRORS').get(msg_id)
|
25
|
+
data = MultiJson.load(msg.body, :symbolize_keys => true)
|
26
|
+
iron.enqueue queue_id, params: data[:params], retries: data[:params] + 1
|
15
27
|
end
|
16
28
|
|
17
29
|
end
|