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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 305004ad44985be958b7f20d71fc83652333252e
4
- data.tar.gz: b5a82ec9b026e57426967bca8227d1012b2578d1
3
+ metadata.gz: cf837908a2b09ae4eeaa6070e358602a58573f56
4
+ data.tar.gz: 9faa17b8dd76fcd5f4dc3b41e64e05f79d3cc591
5
5
  SHA512:
6
- metadata.gz: ba2d3f3cf0326071dc8e4a7ae30dd667390ddc6867b2759491309d81cc594aae87c6a50b8978449d0e82ecd4a12a25f3890bca6692375e9ecd59cfa2c2c35057
7
- data.tar.gz: 95e7c730c8db4ded1f3065c561756c75549133aa9fa7b5ca41f333890cdd28a0b2ea3cd832639a34c0748e090144d531c0d30be6f83d120c1e9ceb8e30fa15f1
6
+ metadata.gz: a22a16531b5cb3fb978e90823ac9e66939f210eaa2d18c0a9d9c144e2c9904ecbad65ddd728d5159d08cbbc931a65d89d6e9ccdf3cc5cba90f6aad9b781fbc19
7
+ data.tar.gz: 616f08c902ff86c3109808a8653db030d660c02b779ebebffda513c5df9473fba462e2974ea749e48ebe3af1c06ef08ff3b26145718f4e80887b844290f4dd25
data/.gitignore CHANGED
@@ -2,3 +2,4 @@ nodes.conf
2
2
  .DS_Store
3
3
  .gs/
4
4
  *.gem
5
+ jobbie/
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "activejob_disque_adapter"
3
- s.version = "0.0.1"
3
+ s.version = "0.0.2"
4
4
  s.summary = "ActiveJob adapter for Disque backends"
5
5
  s.description = "Fills the gap between ActiveJob and Disque"
6
6
  s.authors = ["pote"]
@@ -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
  )
@@ -0,0 +1,4 @@
1
+ module ActiveJob::QueueAdapters
2
+ extend ActiveSupport::Autoload
3
+ autoload :DisqueAdapter
4
+ end
data/lib/active_job.rb ADDED
@@ -0,0 +1,6 @@
1
+ require 'activesupport'
2
+
3
+ module ActiveJob
4
+ extend ActiveSupport::Autoload
5
+ autoload :DisqueWorker
6
+ end
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.1
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-08 00:00:00.000000000 Z
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: