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: 16f3b92f0f5a953fcc9200b6704396461c8be8db
4
- data.tar.gz: a411d13c2d1112634ccf107f7c00d334c098f9cc
3
+ metadata.gz: d5afc1faf82bce74cf7e6919a4bcc89792d5bc99
4
+ data.tar.gz: 0f13f1dee0481bb58fc99f91778a3a46a7b59cf6
5
5
  SHA512:
6
- metadata.gz: b78866acd40c7871893af4e4bb058aeddacc32b7538f5c935ad0070e1cdd59e35ab96ca42eb34450711594ab92e68dd8f3fc23b5e8a5241993d5de4cd08f5002
7
- data.tar.gz: e5d25fc001a9dfb0a20b9b2cbd56b9df593dfafb89700e96282b9fce6a18d46a9b50f015519cb15fefe2efa0963112dd8ea0b00cf8e05f7275554a6e89d407c1
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, :builder
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
- @builder.use middleware, *args
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
- @builder = Vx::Common::Rack::Builder.new
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
- instrument("process_publishing.consumer.amqp", instrumentation) do
28
- m = serialize_message message, options[:content_type]
29
- x.publish m, options
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 with_middlewares(env, &block)
93
- Common::AMQP.config.builder.to_app(block).call(env)
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)
@@ -1,7 +1,7 @@
1
1
  module Vx
2
2
  module Common
3
3
  module AMQP
4
- VERSION = "0.3.5"
4
+ VERSION = "0.3.6"
5
5
  end
6
6
  end
7
7
  end
@@ -10,8 +10,13 @@ describe Vx::Common::AMQP::Config do
10
10
  end
11
11
  end
12
12
 
13
- config.use mid
14
- rs = config.builder.to_app(->(e) { e }).call({})
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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vx-common-amqp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Galinsky