rails_push_queues 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -1
- data/app/controllers/queues_controller.rb +11 -7
- data/lib/rails_push_queues/sidekiq.rb +1 -1
- data/lib/rails_push_queues/version.rb +1 -1
- data/lib/tasks/rails_push_queues_tasks.rake +11 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0cc2b27470da56768230d5891c20b1be4723470
|
4
|
+
data.tar.gz: 64bd3042793b3f5feeefb1b9d449361cf8918608
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1bbbc4455c53141ba26462158edbbf51dd9b6d46d710096cf10502c469c40edca37e86074c2097a4a2bd3c8b5ce07c1ff32a9ec195c1259178c7274601529eb2
|
7
|
+
data.tar.gz: 6d43957ad03d7e9162385c778887d756027ec224e7153f6cdd62f9bdb6d476dba56b0556cf07f409b18d93bfdd5153356546ce54737a8cac3a9c1a6961e61804
|
data/README.md
CHANGED
@@ -8,11 +8,20 @@ You can easily use Resque and/or Sidekiq workers without change.
|
|
8
8
|
|
9
9
|
LINK TO iron config stuff, iron.json or ENV vars.
|
10
10
|
|
11
|
+
On Heroku, just add the IronMQ add on: `heroku addons:add iron_mq`
|
12
|
+
|
13
|
+
|
11
14
|
## Register the workers
|
12
15
|
|
13
16
|
This is basically creating queues for each worker and setting your application as the subscriber.
|
14
17
|
|
15
18
|
```
|
16
|
-
rake queues:subscribe
|
19
|
+
rake queues:subscribe\[ImageConversionWorker,http://enigmatic-falls-123.herokuapp.com/queues/receive\]
|
20
|
+
```
|
21
|
+
|
22
|
+
To verify the subscriber was added, you can run:
|
23
|
+
|
24
|
+
```
|
25
|
+
rake queues:info\[ImageConversionWorker\]
|
17
26
|
```
|
18
27
|
|
@@ -7,13 +7,17 @@ class QueuesController < ApplicationController
|
|
7
7
|
body = request.body.read
|
8
8
|
p body
|
9
9
|
json = JSON.parse(body)
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
10
|
+
begin
|
11
|
+
job = json["class"].constantize.new
|
12
|
+
# the following is for Resque 2.X
|
13
|
+
#json["vars"].each {|k, v| job.instance_variable_set("@#{k}", v) }
|
14
|
+
#job.work
|
15
|
+
args = json["args"]
|
16
|
+
job.perform(*args)
|
17
|
+
render :json => {"got" => "it"}
|
18
|
+
rescue Exception => ex
|
19
|
+
render :status => 500, :json => {"error"=>"#{ex.message}"}
|
20
|
+
end
|
17
21
|
end
|
18
22
|
|
19
23
|
end
|
@@ -4,8 +4,15 @@
|
|
4
4
|
# end
|
5
5
|
|
6
6
|
namespace :queues do
|
7
|
-
task :subscribe, :clz, :
|
8
|
-
|
9
|
-
|
7
|
+
task :subscribe, [:clz, :url] do |t, args|
|
8
|
+
mq = IronMQ::Client.new
|
9
|
+
q = mq.queue(args.clz.to_s)
|
10
|
+
q.add_subscriber(url: args.url)
|
10
11
|
end
|
11
|
-
|
12
|
+
|
13
|
+
task :info, [:clz] do |t, args|
|
14
|
+
mq = IronMQ::Client.new
|
15
|
+
q = mq.queue(args.clz.to_s)
|
16
|
+
p q.info
|
17
|
+
end
|
18
|
+
end
|