lapine 0.0.3 → 0.1.0
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/lapine.rb +9 -2
- data/lib/lapine/{connection.rb → exchange.rb} +5 -1
- data/lib/lapine/version.rb +1 -1
- data/spec/lib/lapine_spec.rb +21 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c903d73c15a42efe4c3714fa857ac2445e323710
|
4
|
+
data.tar.gz: 8586dd9c5d4d2dc8cc1aa54a4e3c4111b06d8485
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88a0490e40a3107ac07c38cf1e39842af4a31a6886036f24e1c0fbfd1d42641aed7cc4352420fb99522c48ded69930a6ca44c549d57b2ac188e687643a164053
|
7
|
+
data.tar.gz: 97bd4d3961e10c83f3bfad031da65061cdb0f3823e52c7c2dcadb19b88bb626788ff20d2069ba2e2377c4a6dd2fef6d3040a0e1324602c0cafbc6e36284c734a
|
data/lib/lapine.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'lapine/version'
|
2
2
|
require 'lapine/configuration'
|
3
|
-
require 'lapine/
|
3
|
+
require 'lapine/exchange'
|
4
4
|
require 'lapine/publisher'
|
5
5
|
|
6
6
|
module Lapine
|
@@ -26,7 +26,14 @@ module Lapine
|
|
26
26
|
exchange = config.exchange_properties[name]
|
27
27
|
raise UndefinedExchange unless exchange
|
28
28
|
return config.exchanges[name].exchange if config.exchanges[name]
|
29
|
-
config.exchanges[name] = Lapine::
|
29
|
+
config.exchanges[name] = Lapine::Exchange.new(name, exchange)
|
30
30
|
config.exchanges[name].exchange
|
31
31
|
end
|
32
|
+
|
33
|
+
def self.close_connections!
|
34
|
+
config.exchanges.values.each do |exchange|
|
35
|
+
exchange.close!
|
36
|
+
config.exchanges.delete exchange.name
|
37
|
+
end
|
38
|
+
end
|
32
39
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'bunny'
|
2
2
|
|
3
3
|
module Lapine
|
4
|
-
class
|
4
|
+
class Exchange
|
5
5
|
attr_reader :conn, :name, :props, :connection_name, :exchange_type
|
6
6
|
|
7
7
|
def initialize(name, properties)
|
@@ -23,5 +23,9 @@ module Lapine
|
|
23
23
|
channel = conn.create_channel
|
24
24
|
@exchange = Bunny::Exchange.new(channel, exchange_type, name, props)
|
25
25
|
end
|
26
|
+
|
27
|
+
def close!
|
28
|
+
@conn.close
|
29
|
+
end
|
26
30
|
end
|
27
31
|
end
|
data/lib/lapine/version.rb
CHANGED
data/spec/lib/lapine_spec.rb
CHANGED
@@ -46,6 +46,27 @@ RSpec.describe Lapine do
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
+
describe '.close_connections!' do
|
50
|
+
let(:connection1) { double('blah connection', close!: true, name: 'blah') }
|
51
|
+
let(:connection2) { double('blargh connection', close!: true, name: 'blargh') }
|
52
|
+
|
53
|
+
before do
|
54
|
+
config.exchanges['blah'] = connection1
|
55
|
+
config.exchanges['blargh'] = connection2
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'calls close on each connection' do
|
59
|
+
Lapine.close_connections!
|
60
|
+
expect(connection1).to have_received(:close!)
|
61
|
+
expect(connection2).to have_received(:close!)
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'clears the exchanges' do
|
65
|
+
Lapine.close_connections!
|
66
|
+
expect(Lapine.config.exchanges).to be_empty
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
49
70
|
describe '.find_exchange' do
|
50
71
|
before do
|
51
72
|
allow(Bunny).to receive(:new).and_return(connection)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lapine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Saxby
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-11-
|
12
|
+
date: 2014-11-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bunny
|
@@ -112,7 +112,7 @@ files:
|
|
112
112
|
- lapine.gemspec
|
113
113
|
- lib/lapine.rb
|
114
114
|
- lib/lapine/configuration.rb
|
115
|
-
- lib/lapine/
|
115
|
+
- lib/lapine/exchange.rb
|
116
116
|
- lib/lapine/publisher.rb
|
117
117
|
- lib/lapine/version.rb
|
118
118
|
- spec/lib/lapine/publisher_spec.rb
|