vx-consumer 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vx/consumer/publish.rb +1 -5
- data/lib/vx/consumer/session.rb +23 -10
- data/lib/vx/consumer/subscribe.rb +3 -1
- data/lib/vx/consumer/version.rb +1 -1
- data/lib/vx/consumer.rb +4 -0
- data/spec/lib/consumer_spec.rb +1 -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: 855e8429df6a59a3a5ef9343411369be93f3af1a
|
4
|
+
data.tar.gz: 0c7df3bf9e3cc3efca543a5f09ecd0051c209f0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4fcb5d02ba1364f8717e07bc34da09417e73ddffa5b1b4cc851c97822250215a81e66eb8bc8017e42376e58068ea27940528ae38aed426074d021ada219154bd
|
7
|
+
data.tar.gz: b1d57a0b754c90455467b0550086def194a1b790a079a428f4add5bb7be569e30c11da33c7ddc5b4f3c9ef09f24708a15c097ae228ea6be29c52fe82b002dcbe
|
data/lib/vx/consumer/publish.rb
CHANGED
@@ -24,7 +24,7 @@ module Vx
|
|
24
24
|
}
|
25
25
|
|
26
26
|
with_middlewares :pub, instrumentation do
|
27
|
-
|
27
|
+
session.with_pub_channel do |ch|
|
28
28
|
instrument("process_publishing", instrumentation.merge(channel: ch.id)) do
|
29
29
|
encoded = encode_payload(payload, options[:content_type])
|
30
30
|
x = session.declare_exchange ch, name, params.exchange_options
|
@@ -36,10 +36,6 @@ module Vx
|
|
36
36
|
|
37
37
|
private
|
38
38
|
|
39
|
-
def with_channel
|
40
|
-
yield session.pub_channel
|
41
|
-
end
|
42
|
-
|
43
39
|
def encode_payload(payload, content_type)
|
44
40
|
Serializer.pack(content_type, payload)
|
45
41
|
end
|
data/lib/vx/consumer/session.rb
CHANGED
@@ -98,23 +98,36 @@ module Vx
|
|
98
98
|
end
|
99
99
|
end
|
100
100
|
|
101
|
-
def
|
101
|
+
def with_pub_channel
|
102
|
+
key = :vx_consumer_session_pub_channel
|
103
|
+
if ch = Thread.current[key]
|
104
|
+
yield ch
|
105
|
+
else
|
106
|
+
conn.with_channel do |c|
|
107
|
+
yield c
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def allocate_pub_channel
|
102
113
|
assert_connection_is_open
|
103
114
|
|
104
115
|
key = :vx_consumer_session_pub_channel
|
105
|
-
ch = Thread.current[key]
|
106
116
|
|
107
|
-
if
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
unless ch
|
117
|
+
if Thread.current[key]
|
118
|
+
yield
|
119
|
+
else
|
112
120
|
ch = conn.create_channel
|
113
121
|
assign_error_handlers_to_channel(ch)
|
114
|
-
ch
|
122
|
+
Thread.current[key] = ch
|
123
|
+
begin
|
124
|
+
yield
|
125
|
+
ensure
|
126
|
+
ch = Thread.current[key]
|
127
|
+
ch.close if ch.open?
|
128
|
+
Thread.current[key] = nil
|
129
|
+
end
|
115
130
|
end
|
116
|
-
|
117
|
-
ch
|
118
131
|
end
|
119
132
|
|
120
133
|
def declare_exchange(ch, name, options = nil)
|
@@ -33,7 +33,9 @@ module Vx
|
|
33
33
|
with_middlewares :sub, instrumentation do
|
34
34
|
instrument("start_processing", instrumentation)
|
35
35
|
instrument("process", instrumentation) do
|
36
|
-
|
36
|
+
allocate_pub_channel do
|
37
|
+
run_instance delivery_info, properties, payload, channel
|
38
|
+
end
|
37
39
|
end
|
38
40
|
end
|
39
41
|
end
|
data/lib/vx/consumer/version.rb
CHANGED
data/lib/vx/consumer.rb
CHANGED
data/spec/lib/consumer_spec.rb
CHANGED
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.4
|
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-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bunny
|