vx-common-amqp 0.3.4 → 0.3.5
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/common/amqp/config.rb +9 -4
- data/lib/vx/common/amqp/consumer/ack.rb +2 -2
- data/lib/vx/common/amqp/consumer/publish.rb +1 -1
- data/lib/vx/common/amqp/consumer/subscribe.rb +6 -2
- data/lib/vx/common/amqp/mixins/instrument.rb +1 -13
- data/lib/vx/common/amqp/version.rb +1 -1
- data/spec/lib/amqp/config_spec.rb +12 -0
- 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: 16f3b92f0f5a953fcc9200b6704396461c8be8db
|
4
|
+
data.tar.gz: a411d13c2d1112634ccf107f7c00d334c098f9cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b78866acd40c7871893af4e4bb058aeddacc32b7538f5c935ad0070e1cdd59e35ab96ca42eb34450711594ab92e68dd8f3fc23b5e8a5241993d5de4cd08f5002
|
7
|
+
data.tar.gz: e5d25fc001a9dfb0a20b9b2cbd56b9df593dfafb89700e96282b9fce6a18d46a9b50f015519cb15fefe2efa0963112dd8ea0b00cf8e05f7275554a6e89d407c1
|
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'logger'
|
2
1
|
require 'vx/common/rack/builder'
|
3
2
|
|
4
3
|
module Vx
|
@@ -7,8 +6,9 @@ module Vx
|
|
7
6
|
class Config
|
8
7
|
|
9
8
|
attr_accessor :default_exchange_options, :default_queue_options,
|
10
|
-
:default_publish_options, :default_exchange_type, :
|
11
|
-
:heartbeat, :spawn_attempts, :content_type, :instrumenter, :debug,
|
9
|
+
:default_publish_options, :default_exchange_type, :pool_timeout,
|
10
|
+
:heartbeat, :spawn_attempts, :content_type, :instrumenter, :debug,
|
11
|
+
:on_error, :builder
|
12
12
|
|
13
13
|
def initialize
|
14
14
|
reset!
|
@@ -26,8 +26,11 @@ 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
|
31
|
+
end
|
32
|
+
|
29
33
|
def reset!
|
30
|
-
@logger = ::Logger.new(STDOUT)
|
31
34
|
@default_exchange_type = :topic
|
32
35
|
@pool_timeout = 0.1
|
33
36
|
@heartbeat = 10
|
@@ -44,6 +47,8 @@ module Vx
|
|
44
47
|
@instrumenter = nil
|
45
48
|
@on_error = ->(e, env){ nil }
|
46
49
|
|
50
|
+
@builder = Vx::Common::Rack::Builder.new
|
51
|
+
|
47
52
|
@default_exchange_options = {
|
48
53
|
durable: true,
|
49
54
|
auto_delete: false
|
@@ -7,7 +7,7 @@ module Vx
|
|
7
7
|
instrumentation = {
|
8
8
|
consumer_id: self.class.consumer_id,
|
9
9
|
consumer: self.class.consumer_name,
|
10
|
-
|
10
|
+
properties: properties,
|
11
11
|
multiple: multiple,
|
12
12
|
}
|
13
13
|
self.class.session.channel.ack delivery_info.delivery_tag, multiple
|
@@ -18,7 +18,7 @@ module Vx
|
|
18
18
|
instrumentation = {
|
19
19
|
consumer_id: self.class.consumer_id,
|
20
20
|
consumer: self.class.consumer_name,
|
21
|
-
|
21
|
+
properties: properties,
|
22
22
|
multiple: multiple,
|
23
23
|
requeue: requeue,
|
24
24
|
}
|
@@ -64,10 +64,10 @@ module Vx
|
|
64
64
|
consumer_id: consumer_id,
|
65
65
|
consumer: consumer_name,
|
66
66
|
payload: payload,
|
67
|
-
|
67
|
+
properties: properties,
|
68
68
|
}
|
69
69
|
|
70
|
-
|
70
|
+
with_middlewares instrumentation do
|
71
71
|
instrument("start_processing.consumer.amqp", instrumentation)
|
72
72
|
instrument("process.consumer.amqp", instrumentation) do
|
73
73
|
result = run_instance delivery_info, properties, payload, uuid
|
@@ -89,6 +89,10 @@ 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)
|
94
|
+
end
|
95
|
+
|
92
96
|
def deserialize_message(properties, payload)
|
93
97
|
Common::AMQP::Formatter.unpack(
|
94
98
|
properties[:content_type],
|
@@ -3,20 +3,8 @@ module Vx
|
|
3
3
|
module AMQP
|
4
4
|
module Instrument
|
5
5
|
|
6
|
-
def self.with(new_params)
|
7
|
-
old_params = Thread.current["vx_common_amqp_instrument_with"]
|
8
|
-
begin
|
9
|
-
Thread.current["vx_common_amqp_instrument_with"] = new_params
|
10
|
-
yield if block_given?
|
11
|
-
ensure
|
12
|
-
Thread.current["vx_common_amqp_instrument_with"] = old_params
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
6
|
def instrument(name, payload, &block)
|
17
|
-
|
18
|
-
append ||= {}
|
19
|
-
Common::AMQP.instrument name, payload.merge(append), &block
|
7
|
+
Common::AMQP.instrument name, payload, &block
|
20
8
|
end
|
21
9
|
|
22
10
|
end
|
@@ -3,4 +3,16 @@ require 'spec_helper'
|
|
3
3
|
describe Vx::Common::AMQP::Config do
|
4
4
|
let(:config) { described_class.new }
|
5
5
|
|
6
|
+
it "should use builder" do
|
7
|
+
mid = Struct.new(:app) do
|
8
|
+
def call(env)
|
9
|
+
env.merge!(a: 1)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
config.use mid
|
14
|
+
rs = config.builder.to_app(->(e) { e }).call({})
|
15
|
+
expect(rs).to eq(a: 1)
|
16
|
+
end
|
17
|
+
|
6
18
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vx-common-amqp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
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-02-
|
11
|
+
date: 2014-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bunny
|