bunny 0.4.0 → 0.4.1
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/README +1 -1
- data/lib/bunny/client.rb +5 -2
- data/lib/bunny/queue.rb +32 -0
- data/lib/bunny.rb +1 -1
- data/lib/qrack/transport/buffer.rb +10 -1
- data/spec/queue_spec.rb +8 -0
- metadata +2 -3
- data/bunny.gemspec +0 -37
data/README
CHANGED
@@ -17,7 +17,7 @@ You can use Bunny to -
|
|
17
17
|
* Create and delete queues
|
18
18
|
* Publish and consume messages
|
19
19
|
|
20
|
-
Bunny is known to work with RabbitMQ
|
20
|
+
Bunny is known to work with RabbitMQ versions 1.5.4, 1.5.5 and version 0-8 of the AMQP specification.
|
21
21
|
|
22
22
|
=== INSTALL:
|
23
23
|
|
data/lib/bunny/client.rb
CHANGED
@@ -281,9 +281,11 @@ _Bunny_::_ProtocolError_ is raised. If successful, _Client_._status_ is set to <
|
|
281
281
|
end
|
282
282
|
|
283
283
|
def socket
|
284
|
-
return @socket if @socket and not @socket.closed?
|
284
|
+
return @socket if @socket and (@status == :connected) and not @socket.closed?
|
285
285
|
|
286
286
|
begin
|
287
|
+
@status = :not_connected
|
288
|
+
|
287
289
|
# Attempt to connect.
|
288
290
|
@socket = timeout(CONNECT_TIMEOUT) do
|
289
291
|
TCPSocket.new(host, port)
|
@@ -293,7 +295,8 @@ _Bunny_::_ProtocolError_ is raised. If successful, _Client_._status_ is set to <
|
|
293
295
|
@socket.setsockopt Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1
|
294
296
|
end
|
295
297
|
@status = :connected
|
296
|
-
rescue
|
298
|
+
rescue => e
|
299
|
+
@status = :not_connected
|
297
300
|
raise Bunny::ServerDownError, e.message
|
298
301
|
end
|
299
302
|
|
data/lib/bunny/queue.rb
CHANGED
@@ -397,6 +397,38 @@ from queues if successful. If an error occurs raises _Bunny_::_ProtocolError_.
|
|
397
397
|
:delete_ok
|
398
398
|
end
|
399
399
|
|
400
|
+
=begin rdoc
|
401
|
+
|
402
|
+
=== DESCRIPTION:
|
403
|
+
|
404
|
+
Removes all messages from a queue. It does not cancel consumers. Purged messages are deleted
|
405
|
+
without any formal "undo" mechanism. If an error occurs raises _Bunny_::_ProtocolError_.
|
406
|
+
|
407
|
+
==== Options:
|
408
|
+
|
409
|
+
* <tt>:nowait => true or false (_default_)</tt> - Ignored by Bunny, always _false_.
|
410
|
+
|
411
|
+
==== Returns:
|
412
|
+
|
413
|
+
<tt>:purge_ok</tt> if successful
|
414
|
+
=end
|
415
|
+
|
416
|
+
def purge(opts = {})
|
417
|
+
# ignore the :nowait option if passed, otherwise program will hang waiting for a
|
418
|
+
# response that will not be sent by the server
|
419
|
+
opts.delete(:nowait)
|
420
|
+
|
421
|
+
client.send_frame(
|
422
|
+
Qrack::Protocol::Queue::Purge.new({ :queue => name, :nowait => false }.merge(opts))
|
423
|
+
)
|
424
|
+
|
425
|
+
raise Bunny::ProtocolError, "Error purging queue #{name}" unless client.next_method.is_a?(Qrack::Protocol::Queue::PurgeOk)
|
426
|
+
|
427
|
+
# return confirmation
|
428
|
+
:purge_ok
|
429
|
+
|
430
|
+
end
|
431
|
+
|
400
432
|
private
|
401
433
|
def exchange
|
402
434
|
@exchange ||= Bunny::Exchange.new(client, '', {:type => :direct, :key => name})
|
data/lib/bunny.rb
CHANGED
@@ -1,7 +1,16 @@
|
|
1
|
+
if [].map.respond_to? :with_index
|
2
|
+
class Array #:nodoc:
|
3
|
+
def enum_with_index
|
4
|
+
each.with_index
|
5
|
+
end
|
6
|
+
end
|
7
|
+
else
|
8
|
+
require 'enumerator'
|
9
|
+
end
|
10
|
+
|
1
11
|
module Qrack
|
2
12
|
module Transport #:nodoc: all
|
3
13
|
class Buffer
|
4
|
-
require 'enumerator' if RUBY_VERSION < '1.8.7'
|
5
14
|
|
6
15
|
def initialize data = ''
|
7
16
|
@data = data
|
data/spec/queue_spec.rb
CHANGED
@@ -67,6 +67,14 @@ describe Bunny::Queue do
|
|
67
67
|
q.message_count.should == 0
|
68
68
|
end
|
69
69
|
|
70
|
+
it "should be able to be purged to remove all of its messages" do
|
71
|
+
q = @b.queue('test1')
|
72
|
+
5.times {q.publish('This is another test message')}
|
73
|
+
q.message_count.should == 5
|
74
|
+
q.purge
|
75
|
+
q.message_count.should == 0
|
76
|
+
end
|
77
|
+
|
70
78
|
it "should return an empty message when popping an empty queue" do
|
71
79
|
q = @b.queue('test1')
|
72
80
|
q.publish('This is another test message')
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bunny
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Duncan
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-05-
|
12
|
+
date: 2009-05-21 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -25,7 +25,6 @@ files:
|
|
25
25
|
- LICENSE
|
26
26
|
- README
|
27
27
|
- Rakefile
|
28
|
-
- bunny.gemspec
|
29
28
|
- examples/simple.rb
|
30
29
|
- examples/simple_ack.rb
|
31
30
|
- examples/simple_consumer.rb
|
data/bunny.gemspec
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
Gem::Specification.new do |s|
|
2
|
-
s.name = %q{bunny}
|
3
|
-
s.version = "0.4.0"
|
4
|
-
s.authors = ["Chris Duncan"]
|
5
|
-
s.date = %q{2009-05-15}
|
6
|
-
s.description = %q{Another synchronous Ruby AMQP client}
|
7
|
-
s.email = %q{celldee@gmail.com}
|
8
|
-
s.rubyforge_project = %q{bunny-amqp}
|
9
|
-
s.has_rdoc = true
|
10
|
-
s.extra_rdoc_files = [ "README" ]
|
11
|
-
s.rdoc_options = [ "--main", "README" ]
|
12
|
-
s.homepage = %q{http://github.com/celldee/bunny}
|
13
|
-
s.summary = %q{A synchronous Ruby AMQP client that enables interaction with AMQP-compliant brokers/servers.}
|
14
|
-
s.files = ["LICENSE",
|
15
|
-
"README",
|
16
|
-
"Rakefile",
|
17
|
-
"bunny.gemspec",
|
18
|
-
"examples/simple.rb",
|
19
|
-
"examples/simple_ack.rb",
|
20
|
-
"examples/simple_consumer.rb",
|
21
|
-
"examples/simple_fanout.rb",
|
22
|
-
"examples/simple_publisher.rb",
|
23
|
-
"examples/simple_topic.rb",
|
24
|
-
"lib/bunny.rb",
|
25
|
-
"lib/bunny/client.rb",
|
26
|
-
"lib/bunny/exchange.rb",
|
27
|
-
"lib/bunny/queue.rb",
|
28
|
-
"lib/qrack/client.rb",
|
29
|
-
"lib/qrack/protocol/protocol.rb",
|
30
|
-
"lib/qrack/protocol/spec.rb",
|
31
|
-
"lib/qrack/qrack.rb",
|
32
|
-
"lib/qrack/transport/buffer.rb",
|
33
|
-
"lib/qrack/transport/frame.rb",
|
34
|
-
"spec/bunny_spec.rb",
|
35
|
-
"spec/exchange_spec.rb",
|
36
|
-
"spec/queue_spec.rb"]
|
37
|
-
end
|