asynchronic 2.0.0 → 2.0.1

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: 7a0200ef4e9c9c465ddc70786d71e15bb2fa2f4d
4
- data.tar.gz: 0d5320739a21a0cd57f7e65cfe28d6dea571dbfb
3
+ metadata.gz: 1e125dac6480974894d48275d0015bb85410a9f4
4
+ data.tar.gz: 07b4801fd659a5c0735ccac5dc24c5340363afa8
5
5
  SHA512:
6
- metadata.gz: 2294c1215c7b3abb787c3ec9cd955b254b9b1ec235e6c028d1ff9620b881bc0f0a7ed937b98b14e1ef2537b0be2921e67772ccaec1d9b37616bccc8a11fbe8cf
7
- data.tar.gz: 8fa59d9eeafa9a952a9c76c2b91c807d4eaa0fcbc58ee2b1bed1bd637358b42f4c2ef8e1fb1bb864bad86664e45c67fbc44e8bd8e2099dedda6b6e08e95e6cc2
6
+ metadata.gz: d68006d635184823ac8bcdc4669690b4778b295b4eb98c5b8b4375c0284be30db220ee87bf3f6f7fc932365adb26a3196116b6549ef3432fa2391ec1395f7363
7
+ data.tar.gz: 630f880110f71041ab2bc18f5ad5258298b8f3d18560315569aa18ed8459986af20c3768cc3dc77992c82db3d2dce496125ad4931902cddd6ad11d4aaa8fe09e
@@ -8,7 +8,8 @@ rvm:
8
8
  - 2.4.0
9
9
  - 2.5.0
10
10
  - 2.6.0
11
- - jruby-9.1.7.0
11
+ - jruby-9.1.17.0
12
+ - jruby-9.2.7.0
12
13
  - ruby-head
13
14
  - jruby-head
14
15
 
@@ -2,12 +2,12 @@ module Asynchronic
2
2
  module QueueEngine
3
3
  class Ost
4
4
 
5
- attr_reader :default_queue
5
+ attr_reader :redis, :default_queue
6
6
 
7
7
  def initialize(options={})
8
8
  @redis = Redic.new(*Array(options[:redis]))
9
9
  @default_queue = options.fetch(:default_queue, Asynchronic.default_queue)
10
- @queues ||= Hash.new { |h,k| h[k] = Queue.new k }
10
+ @queues ||= Hash.new { |h,k| h[k] = Queue.new k, redis }
11
11
  @keep_alive_thread = notify_keep_alive
12
12
  end
13
13
 
@@ -16,12 +16,12 @@ module Asynchronic
16
16
  end
17
17
 
18
18
  def queues
19
- (@queues.values.map(&:key) | @redis.call('KEYS', 'ost:*')).map { |q| q.to_s[4..-1].to_sym }
19
+ (@queues.values.map(&:key) | redis.call('KEYS', 'ost:*')).map { |q| q.to_s[4..-1].to_sym }
20
20
  end
21
21
 
22
22
  def clear
23
23
  @queues.clear
24
- @redis.call('KEYS', 'ost:*').each { |k| @redis.call('DEL', k) }
24
+ redis.call('KEYS', 'ost:*').each { |k| redis.call('DEL', k) }
25
25
  end
26
26
 
27
27
  def listener
@@ -33,7 +33,7 @@ module Asynchronic
33
33
  end
34
34
 
35
35
  def active_connections
36
- @redis.call('CLIENT', 'LIST').split("\n").map do |connection_info|
36
+ redis.call('CLIENT', 'LIST').split("\n").map do |connection_info|
37
37
  connection_info.split(' ').detect { |a| a.match(/name=/) }[5..-1]
38
38
  end.uniq.reject(&:empty?)
39
39
  end
@@ -43,7 +43,7 @@ module Asynchronic
43
43
  def notify_keep_alive
44
44
  Thread.new do
45
45
  loop do
46
- @redis.call 'CLIENT', 'SETNAME', Asynchronic.connection_name
46
+ redis.call 'CLIENT', 'SETNAME', Asynchronic.connection_name
47
47
  sleep Asynchronic.keep_alive_timeout
48
48
  end
49
49
  end
@@ -52,6 +52,11 @@ module Asynchronic
52
52
 
53
53
  class Queue < ::Ost::Queue
54
54
 
55
+ def initialize(name, redis)
56
+ super name
57
+ self.redis = redis
58
+ end
59
+
55
60
  def pop
56
61
  redis.call 'RPOP', key
57
62
  end
@@ -1,3 +1,3 @@
1
1
  module Asynchronic
2
- VERSION = '2.0.0'
2
+ VERSION = '2.0.1'
3
3
  end
@@ -11,5 +11,9 @@ describe Asynchronic::QueueEngine::Ost do
11
11
  end
12
12
 
13
13
  include QueueEngineExamples
14
+
15
+ it 'Engine and queues use same redis connection' do
16
+ engine.redis.must_equal queue.redis
17
+ end
14
18
 
15
19
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asynchronic
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriel Naiman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-18 00:00:00.000000000 Z
11
+ date: 2019-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ost