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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8d065ca96355cdfd8cecd879e618fb01e8f352f0
4
- data.tar.gz: ac7301fa769cd9f4cadc87cd2198cc81fa3e96f3
3
+ metadata.gz: 014ac3efcc92a40a6fe079b207ef4fd1aaa20c18
4
+ data.tar.gz: 26e318d49913b320bacba4f1e449f108ab8d64c3
5
5
  SHA512:
6
- metadata.gz: 60f428c2d88ac2d0c3112c955dd03c36f2c4ccd3751a519e3d294a72b58dcab53bb24b622699d57230aa05faada2c5e674d5e5f4445fec45f7e7712fa536d2f3
7
- data.tar.gz: 7191a8138b0c2aa0121ddbb1bba1c577e26581e9217c43e8cce6175cabfeb1d9e49ac77c8f1bb193cd59e9b5d6be4c853acad7a5aba932d4ef6699cdb4606081
6
+ metadata.gz: 93dfa35403a31835cf96bf12d12c8473f310bce257a1a7675053f46dd073fe5f2f32467555eecb4234e1f5b752268393a8650e3a33d5991b53cc4833c3a5c3eb
7
+ data.tar.gz: d504a8b11eb7668610ce3feeb5a99e6bebd497c7b0c6f4db149d0cd130e8c53117c4d286b6ae41ad792e4ac58d958e32aa8c2c58ec8267884da011529ce4c26c
@@ -1,14 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- liebre (0.1.11)
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.6.3)
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)
@@ -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
- @lock.synchronize do
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
- @lock.synchronize do
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
- @lock.synchronize do
55
+ Common::Utils.mutex_sync do
57
56
  connections.each do |_, bunny|
58
57
  if bunny and bunny.open?
59
58
  bunny.close
@@ -1,5 +1,5 @@
1
1
  module Liebre
2
2
 
3
- VERSION = "0.1.13"
3
+ VERSION = "0.1.14"
4
4
 
5
5
  end
@@ -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)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: liebre
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.13
4
+ version: 0.1.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - jcabotc