liebre 0.1.13 → 0.1.14
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/Gemfile.lock +2 -2
- data/lib/liebre/common/utils.rb +10 -1
- data/lib/liebre/connection_manager.rb +3 -4
- data/lib/liebre/version.rb +1 -1
- data/spec/liebre/runner/starter/resources_spec.rb +2 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 014ac3efcc92a40a6fe079b207ef4fd1aaa20c18
|
4
|
+
data.tar.gz: 26e318d49913b320bacba4f1e449f108ab8d64c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93dfa35403a31835cf96bf12d12c8473f310bce257a1a7675053f46dd073fe5f2f32467555eecb4234e1f5b752268393a8650e3a33d5991b53cc4833c3a5c3eb
|
7
|
+
data.tar.gz: d504a8b11eb7668610ce3feeb5a99e6bebd497c7b0c6f4db149d0cd130e8c53117c4d286b6ae41ad792e4ac58d958e32aa8c2c58ec8267884da011529ce4c26c
|
data/Gemfile.lock
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
liebre (0.1.
|
4
|
+
liebre (0.1.13)
|
5
5
|
bunny (~> 2.5, >= 2.5.1)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
10
|
amq-protocol (2.0.1)
|
11
|
-
bunny (2.
|
11
|
+
bunny (2.5.1)
|
12
12
|
amq-protocol (>= 2.0.1)
|
13
13
|
coderay (1.1.1)
|
14
14
|
diff-lcs (1.2.5)
|
data/lib/liebre/common/utils.rb
CHANGED
@@ -1,6 +1,15 @@
|
|
1
1
|
module Liebre
|
2
2
|
module Common
|
3
3
|
module Utils
|
4
|
+
|
5
|
+
@@mutex = Mutex.new
|
6
|
+
|
7
|
+
def self.mutex_sync
|
8
|
+
@@mutex.synchronize do
|
9
|
+
yield
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
4
13
|
def self.create_exchange channel, config
|
5
14
|
exchange_name = config.fetch "name"
|
6
15
|
|
@@ -8,7 +17,7 @@ module Liebre
|
|
8
17
|
opts = config.fetch("opts", {})
|
9
18
|
exchange_opts = symbolize_keys(opts.merge("type" => type))
|
10
19
|
|
11
|
-
channel.exchange exchange_name, exchange_opts
|
20
|
+
mutex_sync { channel.exchange exchange_name, exchange_opts }
|
12
21
|
end
|
13
22
|
|
14
23
|
def self.symbolize_keys hash
|
@@ -11,11 +11,10 @@ module Liebre
|
|
11
11
|
@path = Liebre::Config.connection_path
|
12
12
|
@connections = {}
|
13
13
|
@channels = {}
|
14
|
-
@lock = Mutex.new
|
15
14
|
end
|
16
15
|
|
17
16
|
def start
|
18
|
-
|
17
|
+
Common::Utils.mutex_sync do
|
19
18
|
initialize_connections
|
20
19
|
connections.each do |connection_name, bunny|
|
21
20
|
begin
|
@@ -45,7 +44,7 @@ module Liebre
|
|
45
44
|
end
|
46
45
|
|
47
46
|
def channel_for connection_name, consumer_pool_size = 1
|
48
|
-
|
47
|
+
Common::Utils.mutex_sync do
|
49
48
|
channels[connection_name] ||= begin
|
50
49
|
get(connection_name).create_channel nil, consumer_pool_size
|
51
50
|
end
|
@@ -53,7 +52,7 @@ module Liebre
|
|
53
52
|
end
|
54
53
|
|
55
54
|
def stop
|
56
|
-
|
55
|
+
Common::Utils.mutex_sync do
|
57
56
|
connections.each do |_, bunny|
|
58
57
|
if bunny and bunny.open?
|
59
58
|
bunny.close
|
data/lib/liebre/version.rb
CHANGED
@@ -19,6 +19,8 @@ RSpec.describe Liebre::Runner::Starter::Resources do
|
|
19
19
|
before do
|
20
20
|
allow(connection).to receive(:create_channel).
|
21
21
|
with(nil, pool_size).and_return(channel)
|
22
|
+
|
23
|
+
allow(channel).to receive(:prefetch).with(10)
|
22
24
|
|
23
25
|
allow(channel).to receive(:default_exchange).
|
24
26
|
and_return(exchange)
|