beetle 0.2.9.6 → 0.2.9.7
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
CHANGED
@@ -78,7 +78,7 @@ module Beetle
|
|
78
78
|
def client_started(payload)
|
79
79
|
id = payload["id"]
|
80
80
|
if client_id_valid?(id)
|
81
|
-
logger.info("Received client_started message from id #{id}")
|
81
|
+
logger.info("Received client_started message from id '#{id}'")
|
82
82
|
else
|
83
83
|
msg = "Received client_started message from unknown id '#{id}'"
|
84
84
|
logger.error(msg)
|
data/lib/beetle/subscriber.rb
CHANGED
@@ -55,7 +55,7 @@ module Beetle
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def queues_for_exchanges(exchanges)
|
58
|
-
@client.exchanges.slice(*exchanges).map{|_, opts| opts[:queues]}.flatten.uniq
|
58
|
+
@client.exchanges.slice(*exchanges).map{|_, opts| opts[:queues]}.flatten.compact.uniq
|
59
59
|
end
|
60
60
|
|
61
61
|
def create_exchanges(exchanges)
|
@@ -189,6 +189,27 @@ module Beetle
|
|
189
189
|
@pub.expects(:publish_with_failover).with("mama-exchange", "mama", @data, @opts).returns(1)
|
190
190
|
assert_equal 1, @pub.publish("mama", @data)
|
191
191
|
end
|
192
|
+
|
193
|
+
test "failover publishing should raise an exception if the message was published to no server" do
|
194
|
+
failover = sequence("failover")
|
195
|
+
@pub.servers = ["someserver", "someotherserver"]
|
196
|
+
@pub.server = "someserver"
|
197
|
+
|
198
|
+
e = mock("exchange")
|
199
|
+
@pub.expects(:exchange).with("mama-exchange").returns(e).in_sequence(failover)
|
200
|
+
e.expects(:publish).raises(Bunny::ConnectionError).in_sequence(failover)
|
201
|
+
@pub.expects(:exchange).with("mama-exchange").returns(e).in_sequence(failover)
|
202
|
+
e.expects(:publish).raises(Bunny::ConnectionError).in_sequence(failover)
|
203
|
+
@pub.expects(:exchange).with("mama-exchange").returns(e).in_sequence(failover)
|
204
|
+
e.expects(:publish).raises(Bunny::ConnectionError).in_sequence(failover)
|
205
|
+
@pub.expects(:exchange).with("mama-exchange").returns(e).in_sequence(failover)
|
206
|
+
e.expects(:publish).raises(Bunny::ConnectionError).in_sequence(failover)
|
207
|
+
|
208
|
+
assert_raises Beetle::NoMessageSent do
|
209
|
+
@pub.publish_with_failover("mama-exchange", "mama", @data, @opts)
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
192
213
|
end
|
193
214
|
|
194
215
|
class PublisherQueueManagementTest < Test::Unit::TestCase
|
@@ -300,5 +300,14 @@ module Beetle
|
|
300
300
|
@server.logger.expects(:error).with(msg)
|
301
301
|
@server.client_started(payload)
|
302
302
|
end
|
303
|
+
|
304
|
+
test "should log an info about received client_started client_started messages" do
|
305
|
+
payload = {"id" => "known-client"}
|
306
|
+
msg = "Received client_started message from id 'known-client'"
|
307
|
+
@server.logger.expects(:info).with(msg)
|
308
|
+
@server.expects(:client_id_valid?).with('known-client').returns(true)
|
309
|
+
@server.client_started(payload)
|
310
|
+
end
|
311
|
+
|
303
312
|
end
|
304
313
|
end
|
@@ -44,7 +44,12 @@ module Beetle
|
|
44
44
|
assert_equal 42, mqs[@sub.server]
|
45
45
|
end
|
46
46
|
|
47
|
-
test "stop! should stop the event loop" do
|
47
|
+
test "stop! should close all amqp connections and then stop the event loop" do
|
48
|
+
connection1 = mock('con1')
|
49
|
+
connection1.expects(:close).yields
|
50
|
+
connection2 = mock('con2')
|
51
|
+
connection2.expects(:close).yields
|
52
|
+
@sub.instance_variable_set "@amqp_connections", [["server1", connection1], ["server2",connection2]]
|
48
53
|
EM.expects(:stop_event_loop)
|
49
54
|
@sub.send(:stop!)
|
50
55
|
end
|
@@ -103,6 +108,10 @@ module Beetle
|
|
103
108
|
@sub.send(:bind_queues, %W(x y))
|
104
109
|
end
|
105
110
|
|
111
|
+
test "should not try to bind a queue for an exchange which has no queue" do
|
112
|
+
@client.register_message(:without_queue)
|
113
|
+
assert_equal [], @sub.send(:queues_for_exchanges, ["without_queue"])
|
114
|
+
end
|
106
115
|
end
|
107
116
|
|
108
117
|
class SubscriberExchangeManagementTest < Test::Unit::TestCase
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: beetle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 117
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
9
|
- 9
|
10
|
-
-
|
11
|
-
version: 0.2.9.
|
10
|
+
- 7
|
11
|
+
version: 0.2.9.7
|
12
12
|
platform: ruby
|
13
13
|
authors:
|
14
14
|
- Stefan Kaes
|
@@ -19,7 +19,7 @@ autorequire:
|
|
19
19
|
bindir: bin
|
20
20
|
cert_chain: []
|
21
21
|
|
22
|
-
date: 2010-12-
|
22
|
+
date: 2010-12-02 00:00:00 +01:00
|
23
23
|
default_executable: beetle
|
24
24
|
dependencies:
|
25
25
|
- !ruby/object:Gem::Dependency
|