vx-consumer 0.1.5 → 0.1.6
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 +4 -4
- data/lib/vx/consumer/subscriber.rb +14 -0
- data/lib/vx/consumer/version.rb +1 -1
- data/spec/lib/consumer_spec.rb +21 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 47b8bcadacba1121ca2956db329217f76ce4e9b6
|
4
|
+
data.tar.gz: 679bba4a1158a235190ac403ef9919d6e198cf44
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2bed198aba1934ca5a6d459a63c438e94193412b145e18b9dbce5217ceebaeeb179d70fc1b2fc2ba6ea8b7ca0dba2e3f846f1cefd57965cf68079177477326eb
|
7
|
+
data.tar.gz: a7d709c2fd93a2b10a5e081b9297580a81e76571a5b61f62496a20af82c1f973505c9486e5a4481b73cec318d19d0845b7ad4d43cd1527746cb0081547709631
|
@@ -19,6 +19,20 @@ module Vx
|
|
19
19
|
in_progress { cancel }
|
20
20
|
end
|
21
21
|
|
22
|
+
def try_graceful_shutdown
|
23
|
+
if @lock.try_lock
|
24
|
+
begin
|
25
|
+
instrument('graceful_shutdown_consumer', consumer: vx_consumer_name)
|
26
|
+
cancel
|
27
|
+
ensure
|
28
|
+
@lock.unlock
|
29
|
+
end
|
30
|
+
true
|
31
|
+
else
|
32
|
+
false
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
22
36
|
def in_progress
|
23
37
|
@lock.synchronize do
|
24
38
|
yield
|
data/lib/vx/consumer/version.rb
CHANGED
data/spec/lib/consumer_spec.rb
CHANGED
@@ -110,7 +110,7 @@ describe Vx::Consumer do
|
|
110
110
|
expect(Bob._collected.map(&:values).flatten.sort).to eq [1,2]
|
111
111
|
end
|
112
112
|
|
113
|
-
it "should work with
|
113
|
+
it "should work with graceful_shutdown" do
|
114
114
|
Bob.timeout = 1
|
115
115
|
|
116
116
|
consumer = Bob.subscribe
|
@@ -126,6 +126,26 @@ describe Vx::Consumer do
|
|
126
126
|
expect(Bob._collected).to_not be_empty
|
127
127
|
end
|
128
128
|
|
129
|
+
it "should work with try_graceful_shutdown" do
|
130
|
+
Bob.timeout = 1
|
131
|
+
|
132
|
+
consumer = Bob.subscribe
|
133
|
+
1.times do |n|
|
134
|
+
Bob.publish a: n
|
135
|
+
end
|
136
|
+
|
137
|
+
sleep 0.1
|
138
|
+
expect(consumer.try_graceful_shutdown).to be_false
|
139
|
+
|
140
|
+
Timeout.timeout(2) do
|
141
|
+
while consumer.running?
|
142
|
+
sleep 0.1
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
expect(consumer.try_graceful_shutdown).to be_true
|
147
|
+
end
|
148
|
+
|
129
149
|
it "running? should be true when consumer process task" do
|
130
150
|
Bob.timeout = 1
|
131
151
|
consumer = Bob.subscribe
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vx-consumer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitry Galinsky
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bunny
|