vx-common-amqp 0.3.5 → 0.3.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5afc1faf82bce74cf7e6919a4bcc89792d5bc99
|
4
|
+
data.tar.gz: 0f13f1dee0481bb58fc99f91778a3a46a7b59cf6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d168cbc35a10d915413039e5030b673b64ec4cd588a033132721ca359bc78abc33c30b6287b746b015d239a8a28a67f53e2c32b5353cffab3129586673c9df01
|
7
|
+
data.tar.gz: efa6725e24213122a358adf76ac7e8f411a410fac2bb6c2b122f130a1a11e46b7de4e71998b1a63167bb40236391bfbda2fa144a9f14d22fae219647d0833db8
|
@@ -8,7 +8,7 @@ module Vx
|
|
8
8
|
attr_accessor :default_exchange_options, :default_queue_options,
|
9
9
|
:default_publish_options, :default_exchange_type, :pool_timeout,
|
10
10
|
:heartbeat, :spawn_attempts, :content_type, :instrumenter, :debug,
|
11
|
-
:on_error, :
|
11
|
+
:on_error, :builders
|
12
12
|
|
13
13
|
def initialize
|
14
14
|
reset!
|
@@ -26,8 +26,8 @@ module Vx
|
|
26
26
|
@debug || ENV['VX_COMMON_AMQP_DEBUG']
|
27
27
|
end
|
28
28
|
|
29
|
-
def use(middleware, *args)
|
30
|
-
@
|
29
|
+
def use(target, middleware, *args)
|
30
|
+
@builders[target].use middleware, *args
|
31
31
|
end
|
32
32
|
|
33
33
|
def reset!
|
@@ -47,7 +47,10 @@ module Vx
|
|
47
47
|
@instrumenter = nil
|
48
48
|
@on_error = ->(e, env){ nil }
|
49
49
|
|
50
|
-
@
|
50
|
+
@builders = {
|
51
|
+
pub: Vx::Common::Rack::Builder.new,
|
52
|
+
sub: Vx::Common::Rack::Builder.new
|
53
|
+
}
|
51
54
|
|
52
55
|
@default_exchange_options = {
|
53
56
|
durable: true,
|
@@ -24,9 +24,11 @@ module Vx
|
|
24
24
|
properties: options,
|
25
25
|
}
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
with_pub_middlewares instrumentation do
|
28
|
+
instrument("process_publishing.consumer.amqp", instrumentation) do
|
29
|
+
m = serialize_message message, options[:content_type]
|
30
|
+
x.publish m, options
|
31
|
+
end
|
30
32
|
end
|
31
33
|
|
32
34
|
self
|
@@ -36,6 +38,10 @@ module Vx
|
|
36
38
|
Common::AMQP::Formatter.pack(content_type, message)
|
37
39
|
end
|
38
40
|
|
41
|
+
def with_pub_middlewares(env, &block)
|
42
|
+
Common::AMQP.config.builders[:pub].to_app(block).call(env)
|
43
|
+
end
|
44
|
+
|
39
45
|
end
|
40
46
|
end
|
41
47
|
end
|
@@ -89,8 +89,8 @@ module Vx
|
|
89
89
|
end.perform payload
|
90
90
|
end
|
91
91
|
|
92
|
-
def
|
93
|
-
Common::AMQP.config.
|
92
|
+
def with_sub_middlewares(env, &block)
|
93
|
+
Common::AMQP.config.builders[:sub].to_app(block).call(env)
|
94
94
|
end
|
95
95
|
|
96
96
|
def deserialize_message(properties, payload)
|
@@ -10,8 +10,13 @@ describe Vx::Common::AMQP::Config do
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
config.use mid
|
14
|
-
|
13
|
+
config.use :sub, mid
|
14
|
+
config.use :pub, mid
|
15
|
+
|
16
|
+
rs = config.builders[:pub].to_app(->(e) { e }).call({})
|
17
|
+
expect(rs).to eq(a: 1)
|
18
|
+
|
19
|
+
rs = config.builders[:sub].to_app(->(e) { e }).call({})
|
15
20
|
expect(rs).to eq(a: 1)
|
16
21
|
end
|
17
22
|
|