activejob_disque_adapter 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/activejob_disque_adapter.gemspec +1 -1
- data/lib/active_job/disque_worker.rb +46 -0
- data/lib/active_job/queue_adapters/disque_adapter.rb +1 -1
- data/lib/active_job/queue_adapters.rb +4 -0
- data/lib/active_job.rb +6 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf837908a2b09ae4eeaa6070e358602a58573f56
|
4
|
+
data.tar.gz: 9faa17b8dd76fcd5f4dc3b41e64e05f79d3cc591
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a22a16531b5cb3fb978e90823ac9e66939f210eaa2d18c0a9d9c144e2c9904ecbad65ddd728d5159d08cbbc931a65d89d6e9ccdf3cc5cba90f6aad9b781fbc19
|
7
|
+
data.tar.gz: 616f08c902ff86c3109808a8653db030d660c02b779ebebffda513c5df9473fba462e2974ea749e48ebe3af1c06ef08ff3b26145718f4e80887b844290f4dd25
|
data/.gitignore
CHANGED
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'activesupport'
|
2
|
+
require 'disque'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module ActiveJob
|
6
|
+
class DisqueWorker
|
7
|
+
attr_reader :disque_client,
|
8
|
+
:disque_queues,
|
9
|
+
:disque_timeout,
|
10
|
+
:disque_count
|
11
|
+
|
12
|
+
def self.run
|
13
|
+
new.run
|
14
|
+
end
|
15
|
+
|
16
|
+
def initialize(client: nil , queues: nil, count: 1, timeout: nil)
|
17
|
+
@disque_client = client || Disque.new(
|
18
|
+
ENV.fetch('DISQUE_NODES', 'localhost:7711'),
|
19
|
+
auth: ENV.fetch('DISQUE_AUTH', nil),
|
20
|
+
cycle: ENV.fetch('DISQUE_CYCLE', '20000').to_i
|
21
|
+
)
|
22
|
+
|
23
|
+
@disque_queues = (queues || ENV.fetch('DISQUE_QUEUES','default')).split(',')
|
24
|
+
@disque_count = count
|
25
|
+
@disque_timeout = timeout
|
26
|
+
|
27
|
+
self
|
28
|
+
end
|
29
|
+
|
30
|
+
def run
|
31
|
+
loop do
|
32
|
+
disque_client.fetch(
|
33
|
+
from: disque_queues,
|
34
|
+
timeout: disque_timeout,
|
35
|
+
count: disque_count
|
36
|
+
) do |serialized_job, _|
|
37
|
+
job = JSON.parse(serialized_job)
|
38
|
+
puts "Processing Job: #{ job }"
|
39
|
+
klass = job.fetch('job_class').classify.constantize
|
40
|
+
klass.new(job.fetch('arguments')).perform_now
|
41
|
+
puts "Done"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -24,7 +24,7 @@ module ActiveJob
|
|
24
24
|
@disque_timeout ||= timeout || ENV.fetch('DISQUE_TIMEOUT', '100').to_i
|
25
25
|
|
26
26
|
@disque_client ||= client || Disque.new(
|
27
|
-
ENV.fetch('DISQUE_NODES'),
|
27
|
+
ENV.fetch('DISQUE_NODES', 'localhost:7711'),
|
28
28
|
auth: ENV.fetch('DISQUE_AUTH', nil),
|
29
29
|
cycle: ENV.fetch('DISQUE_CYCLE', '20000').to_i
|
30
30
|
)
|
data/lib/active_job.rb
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activejob_disque_adapter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pote
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: disque
|
@@ -47,6 +47,9 @@ extra_rdoc_files: []
|
|
47
47
|
files:
|
48
48
|
- ".gitignore"
|
49
49
|
- activejob_disque_adapter.gemspec
|
50
|
+
- lib/active_job.rb
|
51
|
+
- lib/active_job/disque_worker.rb
|
52
|
+
- lib/active_job/queue_adapters.rb
|
50
53
|
- lib/active_job/queue_adapters/disque_adapter.rb
|
51
54
|
homepage: https://github.com/pote/activejob_disque_adapter
|
52
55
|
licenses:
|