beetle 0.2.10 → 0.2.11
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.
- data/beetle.gemspec +1 -1
- data/lib/beetle/client.rb +2 -2
- data/test/beetle/client_test.rb +9 -3
- data/test/beetle/publisher_test.rb +1 -1
- metadata +4 -4
data/beetle.gemspec
CHANGED
data/lib/beetle/client.rb
CHANGED
@@ -66,7 +66,7 @@ module Beetle
|
|
66
66
|
def register_exchange(name, options={})
|
67
67
|
name = name.to_s
|
68
68
|
raise ConfigurationError.new("exchange #{name} already configured") if exchanges.include?(name)
|
69
|
-
exchanges[name] = options.symbolize_keys.merge(:type => :topic, :durable => true)
|
69
|
+
exchanges[name] = options.symbolize_keys.merge(:type => :topic, :durable => true, :queues => [])
|
70
70
|
end
|
71
71
|
|
72
72
|
# register a durable, non passive, non auto_deleted queue with the given _name_ and an _options_ hash:
|
@@ -101,7 +101,7 @@ module Beetle
|
|
101
101
|
key = (opts[:key] || name).to_s
|
102
102
|
(bindings[name] ||= []) << {:exchange => exchange, :key => key}
|
103
103
|
register_exchange(exchange) unless exchanges.include?(exchange)
|
104
|
-
queues =
|
104
|
+
queues = exchanges[exchange][:queues]
|
105
105
|
queues << name unless queues.include?(name)
|
106
106
|
end
|
107
107
|
|
data/test/beetle/client_test.rb
CHANGED
@@ -40,7 +40,7 @@ module Beetle
|
|
40
40
|
test "registering an exchange should store it in the configuration with symbolized option keys and force a topic queue and durability" do
|
41
41
|
opts = {"durable" => false, "type" => "fanout"}
|
42
42
|
@client.register_exchange("some_exchange", opts)
|
43
|
-
assert_equal({:durable => true, :type => :topic}, @client.exchanges["some_exchange"])
|
43
|
+
assert_equal({:durable => true, :type => :topic, :queues => []}, @client.exchanges["some_exchange"])
|
44
44
|
end
|
45
45
|
|
46
46
|
test "should convert exchange name to a string when registering an exchange" do
|
@@ -53,6 +53,12 @@ module Beetle
|
|
53
53
|
assert_raises(ConfigurationError){ @client.register_exchange("some_exchange") }
|
54
54
|
end
|
55
55
|
|
56
|
+
test "registering an exchange should initialize the list of queues bound to it" do
|
57
|
+
@client.register_exchange("some_exchange")
|
58
|
+
assert_equal [], @client.exchanges["some_exchange"][:queues]
|
59
|
+
assert_raises(ConfigurationError){ @client.register_exchange("some_exchange") }
|
60
|
+
end
|
61
|
+
|
56
62
|
test "registering a queue should automatically register the corresponding exchange if it doesn't exist yet" do
|
57
63
|
@client.register_queue("some_queue", "durable" => false, "exchange" => "some_exchange")
|
58
64
|
assert @client.exchanges.include?("some_exchange")
|
@@ -119,14 +125,14 @@ module Beetle
|
|
119
125
|
test "registering a message should register a corresponding exchange if it hasn't been registered yet" do
|
120
126
|
opts = { "exchange" => "some_exchange" }
|
121
127
|
@client.register_message("some_message", opts)
|
122
|
-
assert_equal({:durable => true, :type => :topic}, @client.exchanges["some_exchange"])
|
128
|
+
assert_equal({:durable => true, :type => :topic, :queues => []}, @client.exchanges["some_exchange"])
|
123
129
|
end
|
124
130
|
|
125
131
|
test "registering a message should not fail if the exchange has already been registered" do
|
126
132
|
opts = { "exchange" => "some_exchange" }
|
127
133
|
@client.register_exchange("some_exchange")
|
128
134
|
@client.register_message("some_message", opts)
|
129
|
-
assert_equal({:durable => true, :type => :topic}, @client.exchanges["some_exchange"])
|
135
|
+
assert_equal({:durable => true, :type => :topic, :queues => []}, @client.exchanges["some_exchange"])
|
130
136
|
end
|
131
137
|
|
132
138
|
test "should convert message name to a string when registering a message" do
|
@@ -290,7 +290,7 @@ module Beetle
|
|
290
290
|
|
291
291
|
test "accessing a given exchange should create it using the config. further access should return the created exchange" do
|
292
292
|
m = mock("Bunny")
|
293
|
-
m.expects(:exchange).with("some_exchange", :type => :topic, :durable => true).returns(42)
|
293
|
+
m.expects(:exchange).with("some_exchange", :type => :topic, :durable => true, :queues => []).returns(42)
|
294
294
|
@client.register_exchange("some_exchange", :type => :topic, :durable => true)
|
295
295
|
@pub.expects(:bunny).returns(m)
|
296
296
|
ex = @pub.send(:exchange, "some_exchange")
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: beetle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 1
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 11
|
10
|
+
version: 0.2.11
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Stefan Kaes
|
@@ -18,7 +18,7 @@ autorequire:
|
|
18
18
|
bindir: bin
|
19
19
|
cert_chain: []
|
20
20
|
|
21
|
-
date: 2011-
|
21
|
+
date: 2011-02-15 00:00:00 +01:00
|
22
22
|
default_executable: beetle
|
23
23
|
dependencies:
|
24
24
|
- !ruby/object:Gem::Dependency
|