bunny 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -1,6 +1,9 @@
1
1
  = Bunny: A synchronous Ruby AMQP client
2
2
 
3
3
  *GitHub* *repo*: http://github.com/celldee/bunny
4
+ *Rubyforge*: http://rubyforge.org/projects/bunny-amqp
5
+ *Twitter*: http://twitter.com/bunny_amqp
6
+ *Google* *Group*: http://groups.google.com/group/bunny-amqp
4
7
 
5
8
  === DESCRIPTION:
6
9
 
data/Rakefile CHANGED
@@ -1,8 +1,3 @@
1
- task :codegen do
2
- sh 'ruby ext/codegen.rb > lib/bunny/protocol/spec.rb'
3
- sh 'ruby lib/bunny/protocol/spec.rb'
4
- end
5
-
6
1
  task :spec do
7
2
  require 'spec/rake/spectask'
8
3
  Spec::Rake::SpecTask.new do |t|
@@ -1,8 +1,8 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = %q{bunny}
3
- s.version = "0.3.1"
3
+ s.version = "0.4.0"
4
4
  s.authors = ["Chris Duncan"]
5
- s.date = %q{2009-05-10}
5
+ s.date = %q{2009-05-15}
6
6
  s.description = %q{Another synchronous Ruby AMQP client}
7
7
  s.email = %q{celldee@gmail.com}
8
8
  s.rubyforge_project = %q{bunny-amqp}
@@ -12,26 +12,26 @@ Gem::Specification.new do |s|
12
12
  s.homepage = %q{http://github.com/celldee/bunny}
13
13
  s.summary = %q{A synchronous Ruby AMQP client that enables interaction with AMQP-compliant brokers/servers.}
14
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
- "ext/amqp-0.8.json",
25
- "ext/codegen.rb",
26
- "lib/bunny.rb",
27
- "lib/bunny/client.rb",
28
- "lib/bunny/exchange.rb",
29
- "lib/bunny/protocol/protocol.rb",
30
- "lib/bunny/protocol/spec.rb",
31
- "lib/bunny/queue.rb",
32
- "lib/bunny/transport/buffer.rb",
33
- "lib/bunny/transport/frame.rb",
34
- "spec/bunny_spec.rb",
35
- "spec/exchange_spec.rb",
36
- "spec/queue_spec.rb"]
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
37
  end
@@ -5,29 +5,22 @@ $:.unshift File.expand_path(File.dirname(__FILE__))
5
5
  require file
6
6
  end
7
7
 
8
+ require 'qrack/qrack'
9
+
8
10
  require 'bunny/client'
9
11
  require 'bunny/exchange'
10
12
  require 'bunny/queue'
11
13
 
12
- require 'bunny/protocol/spec'
13
- require 'bunny/protocol/protocol'
14
-
15
- require 'bunny/transport/buffer'
16
- require 'bunny/transport/frame'
17
-
18
14
  module Bunny
19
15
 
20
- include Protocol
21
- include Transport
16
+ include Qrack
22
17
 
23
18
  class ProtocolError < StandardError; end
24
19
  class ServerDownError < StandardError; end
25
- class BufferOverflowError < StandardError; end
26
- class InvalidTypeError < StandardError; end
27
20
  class ConnectionError < StandardError; end
28
21
  class MessageError < StandardError; end
29
22
 
30
- VERSION = '0.3.1'
23
+ VERSION = '0.4.0'
31
24
 
32
25
  # Returns the Bunny version number
33
26
 
@@ -8,7 +8,7 @@ The Client class provides the major Bunny API methods.
8
8
 
9
9
  =end
10
10
 
11
- class Client
11
+ class Client < Qrack::Client
12
12
  CONNECT_TIMEOUT = 1.0
13
13
  RETRY_DELAY = 10.0
14
14
 
@@ -40,7 +40,7 @@ Sets up a Bunny::Client object ready for connection to a broker/server. _Client_
40
40
 
41
41
  def initialize(opts = {})
42
42
  @host = opts[:host] || 'localhost'
43
- @port = opts[:port] || Protocol::PORT
43
+ @port = opts[:port] || Qrack::Protocol::PORT
44
44
  @user = opts[:user] || 'guest'
45
45
  @pass = opts[:pass] || 'guest'
46
46
  @vhost = opts[:vhost] || '/'
@@ -145,7 +145,7 @@ Returns hash of queues declared by Bunny.
145
145
  def send_frame(*args)
146
146
  args.each do |data|
147
147
  data.ticket = ticket if ticket and data.respond_to?(:ticket=)
148
- data = data.to_frame(channel) unless data.is_a?(Transport::Frame)
148
+ data = data.to_frame(channel) unless data.is_a?(Qrack::Transport::Frame)
149
149
  data.channel = channel
150
150
 
151
151
  log :send, data
@@ -155,7 +155,7 @@ Returns hash of queues declared by Bunny.
155
155
  end
156
156
 
157
157
  def next_frame
158
- frame = Transport::Frame.parse(buffer)
158
+ frame = Qrack::Transport::Frame.parse(buffer)
159
159
  log :received, frame
160
160
  frame
161
161
  end
@@ -166,7 +166,7 @@ Returns hash of queues declared by Bunny.
166
166
 
167
167
  def next_payload
168
168
  frame = next_frame
169
- frame.payload
169
+ frame and frame.payload
170
170
  end
171
171
 
172
172
  =begin rdoc
@@ -184,15 +184,15 @@ _Bunny_::_ProtocolError_ is raised. If successful, _Client_._status_ is set to <
184
184
 
185
185
  def close
186
186
  send_frame(
187
- Protocol::Channel::Close.new(:reply_code => 200, :reply_text => 'bye', :method_id => 0, :class_id => 0)
187
+ Qrack::Protocol::Channel::Close.new(:reply_code => 200, :reply_text => 'bye', :method_id => 0, :class_id => 0)
188
188
  )
189
- raise Bunny::ProtocolError, "Error closing channel #{channel}" unless next_method.is_a?(Protocol::Channel::CloseOk)
189
+ raise Bunny::ProtocolError, "Error closing channel #{channel}" unless next_method.is_a?(Qrack::Protocol::Channel::CloseOk)
190
190
 
191
191
  self.channel = 0
192
192
  send_frame(
193
- Protocol::Connection::Close.new(:reply_code => 200, :reply_text => 'Goodbye', :class_id => 0, :method_id => 0)
193
+ Qrack::Protocol::Connection::Close.new(:reply_code => 200, :reply_text => 'Goodbye', :class_id => 0, :method_id => 0)
194
194
  )
195
- raise Bunny::ProtocolError, "Error closing connection" unless next_method.is_a?(Protocol::Connection::CloseOk)
195
+ raise Bunny::ProtocolError, "Error closing connection" unless next_method.is_a?(Qrack::Protocol::Connection::CloseOk)
196
196
 
197
197
  close_socket
198
198
  end
@@ -222,12 +222,12 @@ _Bunny_::_ProtocolError_ is raised. If successful, _Client_._status_ is set to <
222
222
 
223
223
  def start_session
224
224
  @channel = 0
225
- write(Protocol::HEADER)
226
- write([1, 1, Protocol::VERSION_MAJOR, Protocol::VERSION_MINOR].pack('C4'))
227
- raise Bunny::ProtocolError, 'Connection initiation failed' unless next_method.is_a?(Protocol::Connection::Start)
225
+ write(Qrack::Protocol::HEADER)
226
+ write([1, 1, Qrack::Protocol::VERSION_MAJOR, Qrack::Protocol::VERSION_MINOR].pack('C4'))
227
+ raise Bunny::ProtocolError, 'Connection initiation failed' unless next_method.is_a?(Qrack::Protocol::Connection::Start)
228
228
 
229
229
  send_frame(
230
- Protocol::Connection::StartOk.new(
230
+ Qrack::Protocol::Connection::StartOk.new(
231
231
  {:platform => 'Ruby', :product => 'Bunny', :information => 'http://github.com/celldee/bunny', :version => VERSION},
232
232
  'AMQPLAIN',
233
233
  {:LOGIN => @user, :PASSWORD => @pass},
@@ -238,26 +238,26 @@ _Bunny_::_ProtocolError_ is raised. If successful, _Client_._status_ is set to <
238
238
  method = next_method
239
239
  raise Bunny::ProtocolError, "Connection failed - user: #{@user}, pass: #{@pass}" if method.nil?
240
240
 
241
- if method.is_a?(Protocol::Connection::Tune)
241
+ if method.is_a?(Qrack::Protocol::Connection::Tune)
242
242
  send_frame(
243
- Protocol::Connection::TuneOk.new( :channel_max => 0, :frame_max => 131072, :heartbeat => 0)
243
+ Qrack::Protocol::Connection::TuneOk.new( :channel_max => 0, :frame_max => 131072, :heartbeat => 0)
244
244
  )
245
245
  end
246
246
 
247
247
  send_frame(
248
- Protocol::Connection::Open.new(:virtual_host => @vhost, :capabilities => '', :insist => @insist)
248
+ Qrack::Protocol::Connection::Open.new(:virtual_host => @vhost, :capabilities => '', :insist => @insist)
249
249
  )
250
- raise Bunny::ProtocolError, 'Cannot open connection' unless next_method.is_a?(Protocol::Connection::OpenOk)
250
+ raise Bunny::ProtocolError, 'Cannot open connection' unless next_method.is_a?(Qrack::Protocol::Connection::OpenOk)
251
251
 
252
252
  @channel = 1
253
- send_frame(Protocol::Channel::Open.new)
254
- raise Bunny::ProtocolError, "Cannot open channel #{channel}" unless next_method.is_a?(Protocol::Channel::OpenOk)
253
+ send_frame(Qrack::Protocol::Channel::Open.new)
254
+ raise Bunny::ProtocolError, "Cannot open channel #{channel}" unless next_method.is_a?(Qrack::Protocol::Channel::OpenOk)
255
255
 
256
256
  send_frame(
257
- Protocol::Access::Request.new(:realm => '/data', :read => true, :write => true, :active => true, :passive => true)
257
+ Qrack::Protocol::Access::Request.new(:realm => '/data', :read => true, :write => true, :active => true, :passive => true)
258
258
  )
259
259
  method = next_method
260
- raise Bunny::ProtocolError, 'Access denied' unless method.is_a?(Protocol::Access::RequestOk)
260
+ raise Bunny::ProtocolError, 'Access denied' unless method.is_a?(Qrack::Protocol::Access::RequestOk)
261
261
  self.ticket = method.ticket
262
262
 
263
263
  # return status
@@ -269,7 +269,7 @@ _Bunny_::_ProtocolError_ is raised. If successful, _Client_._status_ is set to <
269
269
  private
270
270
 
271
271
  def buffer
272
- @buffer ||= Transport::Buffer.new(self)
272
+ @buffer ||= Qrack::Transport::Buffer.new(self)
273
273
  end
274
274
 
275
275
  def send_command(cmd, *args)
@@ -58,14 +58,14 @@ specification that applies to your target broker/server.
58
58
 
59
59
  unless name == "amq.#{type}" or name == ''
60
60
  client.send_frame(
61
- Protocol::Exchange::Declare.new(
61
+ Qrack::Protocol::Exchange::Declare.new(
62
62
  { :exchange => name, :type => type, :nowait => false }.merge(opts)
63
63
  )
64
64
  )
65
65
 
66
66
  raise Bunny::ProtocolError,
67
67
  "Error declaring exchange #{name}: type = #{type}" unless
68
- client.next_method.is_a?(Protocol::Exchange::DeclareOk)
68
+ client.next_method.is_a?(Qrack::Protocol::Exchange::DeclareOk)
69
69
  end
70
70
  end
71
71
 
@@ -98,19 +98,19 @@ nil
98
98
  def publish(data, opts = {})
99
99
  out = []
100
100
 
101
- out << Protocol::Basic::Publish.new(
101
+ out << Qrack::Protocol::Basic::Publish.new(
102
102
  { :exchange => name, :routing_key => opts.delete(:key) || key }.merge(opts)
103
103
  )
104
104
  data = data.to_s
105
- out << Protocol::Header.new(
106
- Protocol::Basic,
105
+ out << Qrack::Protocol::Header.new(
106
+ Qrack::Protocol::Basic,
107
107
  data.length, {
108
108
  :content_type => 'application/octet-stream',
109
109
  :delivery_mode => (opts.delete(:persistent) ? 2 : 1),
110
110
  :priority => 0
111
111
  }.merge(opts)
112
112
  )
113
- out << Transport::Frame::Body.new(data)
113
+ out << Qrack::Transport::Frame::Body.new(data)
114
114
 
115
115
  client.send_frame(*out)
116
116
  end
@@ -140,12 +140,12 @@ if successful. If an error occurs raises _Bunny_::_ProtocolError_.
140
140
  opts.delete(:nowait)
141
141
 
142
142
  client.send_frame(
143
- Protocol::Exchange::Delete.new({ :exchange => name, :nowait => false }.merge(opts))
143
+ Qrack::Protocol::Exchange::Delete.new({ :exchange => name, :nowait => false }.merge(opts))
144
144
  )
145
145
 
146
146
  raise Bunny::ProtocolError,
147
147
  "Error deleting exchange #{name}" unless
148
- client.next_method.is_a?(Protocol::Exchange::DeleteOk)
148
+ client.next_method.is_a?(Qrack::Protocol::Exchange::DeleteOk)
149
149
 
150
150
  client.exchanges.delete(name)
151
151
 
@@ -27,10 +27,10 @@ Queues must be attached to at least one exchange in order to receive messages fr
27
27
  opts.delete(:nowait)
28
28
 
29
29
  client.send_frame(
30
- Protocol::Queue::Declare.new({ :queue => name, :nowait => false }.merge(opts))
30
+ Qrack::Protocol::Queue::Declare.new({ :queue => name, :nowait => false }.merge(opts))
31
31
  )
32
32
 
33
- raise Bunny::ProtocolError, "Error declaring queue #{name}" unless client.next_method.is_a?(Protocol::Queue::DeclareOk)
33
+ raise Bunny::ProtocolError, "Error declaring queue #{name}" unless client.next_method.is_a?(Qrack::Protocol::Queue::DeclareOk)
34
34
  end
35
35
 
36
36
  =begin rdoc
@@ -52,7 +52,7 @@ ask to confirm a single message or a set of messages up to and including a speci
52
52
 
53
53
  def ack
54
54
  client.send_frame(
55
- Protocol::Basic::Ack.new(:delivery_tag => delivery_tag)
55
+ Qrack::Protocol::Basic::Ack.new(:delivery_tag => delivery_tag)
56
56
  )
57
57
 
58
58
  # reset delivery tag
@@ -91,7 +91,7 @@ a hash <tt>{:delivery_tag, :redelivered, :exchange, :routing_key, :message_count
91
91
  ack = opts.delete(:ack)
92
92
 
93
93
  client.send_frame(
94
- Protocol::Basic::Get.new({ :queue => name,
94
+ Qrack::Protocol::Basic::Get.new({ :queue => name,
95
95
  :consumer_tag => name,
96
96
  :no_ack => !ack,
97
97
  :nowait => true }.merge(opts))
@@ -99,9 +99,9 @@ a hash <tt>{:delivery_tag, :redelivered, :exchange, :routing_key, :message_count
99
99
 
100
100
  method = client.next_method
101
101
 
102
- if method.is_a?(Protocol::Basic::GetEmpty) then
102
+ if method.is_a?(Qrack::Protocol::Basic::GetEmpty) then
103
103
  return :queue_empty
104
- elsif !method.is_a?(Protocol::Basic::GetOk)
104
+ elsif !method.is_a?(Qrack::Protocol::Basic::GetOk)
105
105
  raise Bunny::ProtocolError, "Error getting message from queue #{name}"
106
106
  end
107
107
 
@@ -169,7 +169,7 @@ Returns hash {:message_count, :consumer_count}.
169
169
 
170
170
  def status
171
171
  client.send_frame(
172
- Protocol::Queue::Declare.new({ :queue => name, :passive => true })
172
+ Qrack::Protocol::Queue::Declare.new({ :queue => name, :passive => true })
173
173
  )
174
174
  method = client.next_method
175
175
  {:message_count => method.message_count, :consumer_count => method.consumer_count}
@@ -220,7 +220,7 @@ If <tt>:header => false</tt> only message payload is returned.
220
220
  ack = opts.delete(:ack)
221
221
 
222
222
  client.send_frame(
223
- Protocol::Basic::Consume.new({ :queue => name,
223
+ Qrack::Protocol::Basic::Consume.new({ :queue => name,
224
224
  :consumer_tag => consumer_tag,
225
225
  :no_ack => !ack,
226
226
  :nowait => false }.merge(opts))
@@ -228,12 +228,12 @@ If <tt>:header => false</tt> only message payload is returned.
228
228
 
229
229
  raise Bunny::ProtocolError,
230
230
  "Error subscribing to queue #{name}" unless
231
- client.next_method.is_a?(Protocol::Basic::ConsumeOk)
231
+ client.next_method.is_a?(Qrack::Protocol::Basic::ConsumeOk)
232
232
 
233
233
  while true
234
234
  method = client.next_method
235
235
 
236
- break if method.is_a?(Protocol::Basic::CancelOk)
236
+ break if method.is_a?(Qrack::Protocol::Basic::CancelOk)
237
237
 
238
238
  # get delivery tag to use for acknowledge
239
239
  self.delivery_tag = method.delivery_tag if ack
@@ -269,7 +269,7 @@ the server will not send any more messages for that consumer.
269
269
  # response from the server causing an error
270
270
  opts.delete(:nowait)
271
271
 
272
- client.send_frame( Protocol::Basic::Cancel.new({ :consumer_tag => consumer_tag }.merge(opts)))
272
+ client.send_frame( Qrack::Protocol::Basic::Cancel.new({ :consumer_tag => consumer_tag }.merge(opts)))
273
273
 
274
274
  end
275
275
 
@@ -299,7 +299,7 @@ bound to the direct exchange '' by default. If error occurs, a _Bunny_::_Protoco
299
299
 
300
300
  bindings[exchange] = opts
301
301
  client.send_frame(
302
- Protocol::Queue::Bind.new({ :queue => name,
302
+ Qrack::Protocol::Queue::Bind.new({ :queue => name,
303
303
  :exchange => exchange,
304
304
  :routing_key => opts.delete(:key),
305
305
  :nowait => false }.merge(opts))
@@ -307,7 +307,7 @@ bound to the direct exchange '' by default. If error occurs, a _Bunny_::_Protoco
307
307
 
308
308
  raise Bunny::ProtocolError,
309
309
  "Error binding queue #{name}" unless
310
- client.next_method.is_a?(Protocol::Queue::BindOk)
310
+ client.next_method.is_a?(Qrack::Protocol::Queue::BindOk)
311
311
 
312
312
  # return message
313
313
  :bind_ok
@@ -340,7 +340,7 @@ Removes a queue binding from an exchange. If error occurs, a _Bunny_::_ProtocolE
340
340
  bindings.delete(exchange)
341
341
 
342
342
  client.send_frame(
343
- Protocol::Queue::Unbind.new({ :queue => name,
343
+ Qrack::Protocol::Queue::Unbind.new({ :queue => name,
344
344
  :exchange => exchange,
345
345
  :routing_key => opts.delete(:key),
346
346
  :nowait => false }.merge(opts)
@@ -349,7 +349,7 @@ Removes a queue binding from an exchange. If error occurs, a _Bunny_::_ProtocolE
349
349
 
350
350
  raise Bunny::ProtocolError,
351
351
  "Error unbinding queue #{name}" unless
352
- client.next_method.is_a?(Protocol::Queue::UnbindOk)
352
+ client.next_method.is_a?(Qrack::Protocol::Queue::UnbindOk)
353
353
 
354
354
  # return message
355
355
  :unbind_ok
@@ -384,12 +384,12 @@ from queues if successful. If an error occurs raises _Bunny_::_ProtocolError_.
384
384
  opts.delete(:nowait)
385
385
 
386
386
  client.send_frame(
387
- Protocol::Queue::Delete.new({ :queue => name, :nowait => false }.merge(opts))
387
+ Qrack::Protocol::Queue::Delete.new({ :queue => name, :nowait => false }.merge(opts))
388
388
  )
389
389
 
390
390
  raise Bunny::ProtocolError,
391
391
  "Error deleting queue #{name}" unless
392
- client.next_method.is_a?(Protocol::Queue::DeleteOk)
392
+ client.next_method.is_a?(Qrack::Protocol::Queue::DeleteOk)
393
393
 
394
394
  client.queues.delete(name)
395
395
 
@@ -0,0 +1,5 @@
1
+ module Qrack
2
+ # Client ancestor class
3
+ class Client
4
+ end
5
+ end
@@ -1,4 +1,4 @@
1
- module Bunny
1
+ module Qrack
2
2
  module Protocol
3
3
  #:stopdoc:
4
4
  class Class::Method
@@ -1,61 +1,34 @@
1
1
 
2
2
  #:stopdoc:
3
- # this file was autogenerated on Fri May 08 08:23:09 +0100 2009
4
- # using amqp-0.8.json (mtime: Fri May 08 02:14:44 +0100 2009)
3
+ # this file was autogenerated on Fri May 15 10:11:23 +0100 2009
4
+ # using amqp-0.8.xml (mtime: Wed May 06 14:48:51 +0100 2009)
5
5
  #
6
- # DO NOT EDIT! (edit ext/codegen.rb instead, and run `rake codegen`)
6
+ # DO NOT EDIT! (edit ext/qparser.rb and config.yml instead, and run 'ruby qparser.rb')
7
7
 
8
- module Bunny
9
- module Transport
10
- class Frame
11
- def self.types
12
- @types ||= {}
13
- end
14
-
15
- def self.Frame id
16
- (@_base_frames ||= {})[id] ||= Class.new(Frame) do
17
- class_eval %[
18
- def self.inherited klass
19
- klass.const_set(:ID, #{id})
20
- Frame.types[#{id}] = klass
21
- end
22
- ]
23
- end
24
- end
25
-
26
- class Method < Frame( 1 ); end
27
- class Header < Frame( 2 ); end
28
- class Body < Frame( 3 ); end
29
- class OobMethod < Frame( 4 ); end
30
- class OobHeader < Frame( 5 ); end
31
- class OobBody < Frame( 6 ); end
32
- class Trace < Frame( 7 ); end
33
- class Heartbeat < Frame( 8 ); end
34
-
35
- FOOTER = 206
36
- end
37
- end
38
- end
39
-
40
- module Bunny
8
+ module Qrack
41
9
  module Protocol
42
10
  HEADER = "AMQP".freeze
43
11
  VERSION_MAJOR = 8
44
12
  VERSION_MINOR = 0
13
+ REVISION = 0
45
14
  PORT = 5672
46
15
 
47
16
  RESPONSES = {
48
17
  200 => :REPLY_SUCCESS,
49
18
  310 => :NOT_DELIVERED,
50
19
  311 => :CONTENT_TOO_LARGE,
51
- 312 => :NO_ROUTE,
52
- 313 => :NO_CONSUMERS,
20
+ 320 => :CONNECTION_FORCED,
21
+ 402 => :INVALID_PATH,
53
22
  403 => :ACCESS_REFUSED,
54
23
  404 => :NOT_FOUND,
55
24
  405 => :RESOURCE_LOCKED,
56
- 406 => :PRECONDITION_FAILED,
57
- 320 => :CONNECTION_FORCED,
58
- 402 => :INVALID_PATH,
25
+ 502 => :SYNTAX_ERROR,
26
+ 503 => :COMMAND_INVALID,
27
+ 504 => :CHANNEL_ERROR,
28
+ 506 => :RESOURCE_ERROR,
29
+ 530 => :NOT_ALLOWED,
30
+ 540 => :NOT_IMPLEMENTED,
31
+ 541 => :INTERNAL_ERROR,
59
32
  }
60
33
 
61
34
  FIELDS = [
@@ -80,7 +53,7 @@ module Bunny
80
53
  end
81
54
  ]
82
55
  end
83
-
56
+
84
57
  def properties() @properties ||= [] end
85
58
 
86
59
  def id() self::ID end
@@ -97,7 +70,7 @@ module Bunny
97
70
  end
98
71
  ]
99
72
  end
100
-
73
+
101
74
  def arguments() @arguments ||= [] end
102
75
 
103
76
  def parent() Protocol.const_get(self.to_s[/Protocol::(.+?)::/,1]) end
@@ -111,9 +84,9 @@ module Bunny
111
84
  end
112
85
  end
113
86
  end
114
-
87
+
115
88
  def self.methods() @methods ||= {} end
116
-
89
+
117
90
  def self.Method(id, name)
118
91
  @_base_methods ||= {}
119
92
  @_base_methods[id] ||= ::Class.new(Method) do
@@ -147,7 +120,7 @@ module Bunny
147
120
  end
148
121
  end
149
122
 
150
- module Bunny
123
+ module Qrack
151
124
  module Protocol
152
125
  class Connection < Class( 10, :connection ); end
153
126
  class Channel < Class( 20, :channel ); end
@@ -176,61 +149,62 @@ module Bunny
176
149
  class Close < Method( 60, :close ); end
177
150
  class CloseOk < Method( 61, :close_ok ); end
178
151
 
152
+
179
153
  class Start
180
- octet :version_major
181
- octet :version_minor
182
- table :server_properties
183
- longstr :mechanisms
184
- longstr :locales
154
+ octet :version_major
155
+ octet :version_minor
156
+ table :server_properties
157
+ longstr :mechanisms
158
+ longstr :locales
185
159
  end
186
160
 
187
161
  class StartOk
188
- table :client_properties
189
- shortstr :mechanism
190
- longstr :response
191
- shortstr :locale
162
+ table :client_properties
163
+ shortstr :mechanism
164
+ longstr :response
165
+ shortstr :locale
192
166
  end
193
167
 
194
168
  class Secure
195
- longstr :challenge
169
+ longstr :challenge
196
170
  end
197
171
 
198
172
  class SecureOk
199
- longstr :response
173
+ longstr :response
200
174
  end
201
175
 
202
176
  class Tune
203
- short :channel_max
204
- long :frame_max
205
- short :heartbeat
177
+ short :channel_max
178
+ long :frame_max
179
+ short :heartbeat
206
180
  end
207
181
 
208
182
  class TuneOk
209
- short :channel_max
210
- long :frame_max
211
- short :heartbeat
183
+ short :channel_max
184
+ long :frame_max
185
+ short :heartbeat
212
186
  end
213
187
 
214
188
  class Open
215
- shortstr :virtual_host
216
- shortstr :capabilities
217
- bit :insist
189
+ shortstr :virtual_host
190
+ shortstr :capabilities
191
+ bit :insist
218
192
  end
219
193
 
220
194
  class OpenOk
221
- shortstr :known_hosts
195
+ shortstr :known_hosts
222
196
  end
223
197
 
224
198
  class Redirect
225
- shortstr :host
226
- shortstr :known_hosts
199
+ shortstr :host
200
+ shortstr :known_hosts
227
201
  end
228
202
 
229
203
  class Close
230
- short :reply_code
231
- shortstr :reply_text
232
- short :class_id
233
- short :method_id
204
+ short :reply_code
205
+ shortstr :reply_text
206
+ short :class_id
207
+ short :method_id
234
208
  end
235
209
 
236
210
  class CloseOk
@@ -248,32 +222,33 @@ module Bunny
248
222
  class Close < Method( 40, :close ); end
249
223
  class CloseOk < Method( 41, :close_ok ); end
250
224
 
225
+
251
226
  class Open
252
- shortstr :out_of_band
227
+ shortstr :out_of_band
253
228
  end
254
229
 
255
230
  class OpenOk
256
231
  end
257
232
 
258
233
  class Flow
259
- bit :active
234
+ bit :active
260
235
  end
261
236
 
262
237
  class FlowOk
263
- bit :active
238
+ bit :active
264
239
  end
265
240
 
266
241
  class Alert
267
- short :reply_code
268
- shortstr :reply_text
269
- table :details
242
+ short :reply_code
243
+ shortstr :reply_text
244
+ table :details
270
245
  end
271
246
 
272
247
  class Close
273
- short :reply_code
274
- shortstr :reply_text
275
- short :class_id
276
- short :method_id
248
+ short :reply_code
249
+ shortstr :reply_text
250
+ short :class_id
251
+ short :method_id
277
252
  end
278
253
 
279
254
  class CloseOk
@@ -286,17 +261,18 @@ module Bunny
286
261
  class Request < Method( 10, :request ); end
287
262
  class RequestOk < Method( 11, :request_ok ); end
288
263
 
264
+
289
265
  class Request
290
- shortstr :realm
291
- bit :exclusive
292
- bit :passive
293
- bit :active
294
- bit :write
295
- bit :read
266
+ shortstr :realm
267
+ bit :exclusive
268
+ bit :passive
269
+ bit :active
270
+ bit :write
271
+ bit :read
296
272
  end
297
273
 
298
274
  class RequestOk
299
- short :ticket
275
+ short :ticket
300
276
  end
301
277
 
302
278
  end
@@ -308,26 +284,27 @@ module Bunny
308
284
  class Delete < Method( 20, :delete ); end
309
285
  class DeleteOk < Method( 21, :delete_ok ); end
310
286
 
287
+
311
288
  class Declare
312
- short :ticket
313
- shortstr :exchange
314
- shortstr :type
315
- bit :passive
316
- bit :durable
317
- bit :auto_delete
318
- bit :internal
319
- bit :nowait
320
- table :arguments
289
+ short :ticket
290
+ shortstr :exchange
291
+ shortstr :type
292
+ bit :passive
293
+ bit :durable
294
+ bit :auto_delete
295
+ bit :internal
296
+ bit :nowait
297
+ table :arguments
321
298
  end
322
299
 
323
300
  class DeclareOk
324
301
  end
325
302
 
326
303
  class Delete
327
- short :ticket
328
- shortstr :exchange
329
- bit :if_unused
330
- bit :nowait
304
+ short :ticket
305
+ shortstr :exchange
306
+ bit :if_unused
307
+ bit :nowait
331
308
  end
332
309
 
333
310
  class DeleteOk
@@ -348,63 +325,64 @@ module Bunny
348
325
  class Unbind < Method( 50, :unbind ); end
349
326
  class UnbindOk < Method( 51, :unbind_ok ); end
350
327
 
328
+
351
329
  class Declare
352
- short :ticket
353
- shortstr :queue
354
- bit :passive
355
- bit :durable
356
- bit :exclusive
357
- bit :auto_delete
358
- bit :nowait
359
- table :arguments
330
+ short :ticket
331
+ shortstr :queue
332
+ bit :passive
333
+ bit :durable
334
+ bit :exclusive
335
+ bit :auto_delete
336
+ bit :nowait
337
+ table :arguments
360
338
  end
361
339
 
362
340
  class DeclareOk
363
- shortstr :queue
364
- long :message_count
365
- long :consumer_count
341
+ shortstr :queue
342
+ long :message_count
343
+ long :consumer_count
366
344
  end
367
345
 
368
346
  class Bind
369
- short :ticket
370
- shortstr :queue
371
- shortstr :exchange
372
- shortstr :routing_key
373
- bit :nowait
374
- table :arguments
347
+ short :ticket
348
+ shortstr :queue
349
+ shortstr :exchange
350
+ shortstr :routing_key
351
+ bit :nowait
352
+ table :arguments
375
353
  end
376
354
 
377
355
  class BindOk
378
356
  end
379
357
 
380
358
  class Purge
381
- short :ticket
382
- shortstr :queue
383
- bit :nowait
359
+ short :ticket
360
+ shortstr :queue
361
+ bit :nowait
384
362
  end
385
363
 
386
364
  class PurgeOk
387
- long :message_count
365
+ long :message_count
388
366
  end
389
367
 
390
368
  class Delete
391
- short :ticket
392
- shortstr :queue
393
- bit :if_unused
394
- bit :if_empty
395
- bit :nowait
369
+ short :ticket
370
+ shortstr :queue
371
+ bit :if_unused
372
+ bit :if_empty
373
+ bit :nowait
396
374
  end
397
375
 
398
376
  class DeleteOk
399
- long :message_count
377
+ long :message_count
400
378
  end
401
379
 
402
380
  class Unbind
403
- short :ticket
404
- shortstr :queue
405
- shortstr :exchange
406
- shortstr :routing_key
407
- table :arguments
381
+ short :ticket
382
+ shortstr :queue
383
+ shortstr :exchange
384
+ shortstr :routing_key
385
+ table :arguments
408
386
  end
409
387
 
410
388
  class UnbindOk
@@ -444,91 +422,92 @@ module Bunny
444
422
  class Reject < Method( 90, :reject ); end
445
423
  class Recover < Method( 100, :recover ); end
446
424
 
425
+
447
426
  class Qos
448
- long :prefetch_size
449
- short :prefetch_count
450
- bit :global
427
+ long :prefetch_size
428
+ short :prefetch_count
429
+ bit :global
451
430
  end
452
431
 
453
432
  class QosOk
454
433
  end
455
434
 
456
435
  class Consume
457
- short :ticket
458
- shortstr :queue
459
- shortstr :consumer_tag
460
- bit :no_local
461
- bit :no_ack
462
- bit :exclusive
463
- bit :nowait
436
+ short :ticket
437
+ shortstr :queue
438
+ shortstr :consumer_tag
439
+ bit :no_local
440
+ bit :no_ack
441
+ bit :exclusive
442
+ bit :nowait
464
443
  end
465
444
 
466
445
  class ConsumeOk
467
- shortstr :consumer_tag
446
+ shortstr :consumer_tag
468
447
  end
469
448
 
470
449
  class Cancel
471
- shortstr :consumer_tag
472
- bit :nowait
450
+ shortstr :consumer_tag
451
+ bit :nowait
473
452
  end
474
453
 
475
454
  class CancelOk
476
- shortstr :consumer_tag
455
+ shortstr :consumer_tag
477
456
  end
478
457
 
479
458
  class Publish
480
- short :ticket
481
- shortstr :exchange
482
- shortstr :routing_key
483
- bit :mandatory
484
- bit :immediate
459
+ short :ticket
460
+ shortstr :exchange
461
+ shortstr :routing_key
462
+ bit :mandatory
463
+ bit :immediate
485
464
  end
486
465
 
487
466
  class Return
488
- short :reply_code
489
- shortstr :reply_text
490
- shortstr :exchange
491
- shortstr :routing_key
467
+ short :reply_code
468
+ shortstr :reply_text
469
+ shortstr :exchange
470
+ shortstr :routing_key
492
471
  end
493
472
 
494
473
  class Deliver
495
- shortstr :consumer_tag
496
- longlong :delivery_tag
497
- bit :redelivered
498
- shortstr :exchange
499
- shortstr :routing_key
474
+ shortstr :consumer_tag
475
+ longlong :delivery_tag
476
+ bit :redelivered
477
+ shortstr :exchange
478
+ shortstr :routing_key
500
479
  end
501
480
 
502
481
  class Get
503
- short :ticket
504
- shortstr :queue
505
- bit :no_ack
482
+ short :ticket
483
+ shortstr :queue
484
+ bit :no_ack
506
485
  end
507
486
 
508
487
  class GetOk
509
- longlong :delivery_tag
510
- bit :redelivered
511
- shortstr :exchange
512
- shortstr :routing_key
513
- long :message_count
488
+ longlong :delivery_tag
489
+ bit :redelivered
490
+ shortstr :exchange
491
+ shortstr :routing_key
492
+ long :message_count
514
493
  end
515
494
 
516
495
  class GetEmpty
517
- shortstr :cluster_id
496
+ shortstr :cluster_id
518
497
  end
519
498
 
520
499
  class Ack
521
- longlong :delivery_tag
522
- bit :multiple
500
+ longlong :delivery_tag
501
+ bit :multiple
523
502
  end
524
503
 
525
504
  class Reject
526
- longlong :delivery_tag
527
- bit :requeue
505
+ longlong :delivery_tag
506
+ bit :requeue
528
507
  end
529
508
 
530
509
  class Recover
531
- bit :requeue
510
+ bit :requeue
532
511
  end
533
512
 
534
513
  end
@@ -559,83 +538,84 @@ module Bunny
559
538
  class Ack < Method( 90, :ack ); end
560
539
  class Reject < Method( 100, :reject ); end
561
540
 
541
+
562
542
  class Qos
563
- long :prefetch_size
564
- short :prefetch_count
565
- bit :global
543
+ long :prefetch_size
544
+ short :prefetch_count
545
+ bit :global
566
546
  end
567
547
 
568
548
  class QosOk
569
549
  end
570
550
 
571
551
  class Consume
572
- short :ticket
573
- shortstr :queue
574
- shortstr :consumer_tag
575
- bit :no_local
576
- bit :no_ack
577
- bit :exclusive
578
- bit :nowait
552
+ short :ticket
553
+ shortstr :queue
554
+ shortstr :consumer_tag
555
+ bit :no_local
556
+ bit :no_ack
557
+ bit :exclusive
558
+ bit :nowait
579
559
  end
580
560
 
581
561
  class ConsumeOk
582
- shortstr :consumer_tag
562
+ shortstr :consumer_tag
583
563
  end
584
564
 
585
565
  class Cancel
586
- shortstr :consumer_tag
587
- bit :nowait
566
+ shortstr :consumer_tag
567
+ bit :nowait
588
568
  end
589
569
 
590
570
  class CancelOk
591
- shortstr :consumer_tag
571
+ shortstr :consumer_tag
592
572
  end
593
573
 
594
574
  class Open
595
- shortstr :identifier
596
- longlong :content_size
575
+ shortstr :identifier
576
+ longlong :content_size
597
577
  end
598
578
 
599
579
  class OpenOk
600
- longlong :staged_size
580
+ longlong :staged_size
601
581
  end
602
582
 
603
583
  class Stage
604
584
  end
605
585
 
606
586
  class Publish
607
- short :ticket
608
- shortstr :exchange
609
- shortstr :routing_key
610
- bit :mandatory
611
- bit :immediate
612
- shortstr :identifier
587
+ short :ticket
588
+ shortstr :exchange
589
+ shortstr :routing_key
590
+ bit :mandatory
591
+ bit :immediate
592
+ shortstr :identifier
613
593
  end
614
594
 
615
595
  class Return
616
- short :reply_code
617
- shortstr :reply_text
618
- shortstr :exchange
619
- shortstr :routing_key
596
+ short :reply_code
597
+ shortstr :reply_text
598
+ shortstr :exchange
599
+ shortstr :routing_key
620
600
  end
621
601
 
622
602
  class Deliver
623
- shortstr :consumer_tag
624
- longlong :delivery_tag
625
- bit :redelivered
626
- shortstr :exchange
627
- shortstr :routing_key
628
- shortstr :identifier
603
+ shortstr :consumer_tag
604
+ longlong :delivery_tag
605
+ bit :redelivered
606
+ shortstr :exchange
607
+ shortstr :routing_key
608
+ shortstr :identifier
629
609
  end
630
610
 
631
611
  class Ack
632
- longlong :delivery_tag
633
- bit :multiple
612
+ longlong :delivery_tag
613
+ bit :multiple
634
614
  end
635
615
 
636
616
  class Reject
637
- longlong :delivery_tag
638
- bit :requeue
617
+ longlong :delivery_tag
618
+ bit :requeue
639
619
  end
640
620
 
641
621
  end
@@ -657,58 +637,59 @@ module Bunny
657
637
  class Return < Method( 50, :return ); end
658
638
  class Deliver < Method( 60, :deliver ); end
659
639
 
640
+
660
641
  class Qos
661
- long :prefetch_size
662
- short :prefetch_count
663
- long :consume_rate
664
- bit :global
642
+ long :prefetch_size
643
+ short :prefetch_count
644
+ long :consume_rate
645
+ bit :global
665
646
  end
666
647
 
667
648
  class QosOk
668
649
  end
669
650
 
670
651
  class Consume
671
- short :ticket
672
- shortstr :queue
673
- shortstr :consumer_tag
674
- bit :no_local
675
- bit :exclusive
676
- bit :nowait
652
+ short :ticket
653
+ shortstr :queue
654
+ shortstr :consumer_tag
655
+ bit :no_local
656
+ bit :exclusive
657
+ bit :nowait
677
658
  end
678
659
 
679
660
  class ConsumeOk
680
- shortstr :consumer_tag
661
+ shortstr :consumer_tag
681
662
  end
682
663
 
683
664
  class Cancel
684
- shortstr :consumer_tag
685
- bit :nowait
665
+ shortstr :consumer_tag
666
+ bit :nowait
686
667
  end
687
668
 
688
669
  class CancelOk
689
- shortstr :consumer_tag
670
+ shortstr :consumer_tag
690
671
  end
691
672
 
692
673
  class Publish
693
- short :ticket
694
- shortstr :exchange
695
- shortstr :routing_key
696
- bit :mandatory
697
- bit :immediate
674
+ short :ticket
675
+ shortstr :exchange
676
+ shortstr :routing_key
677
+ bit :mandatory
678
+ bit :immediate
698
679
  end
699
680
 
700
681
  class Return
701
- short :reply_code
702
- shortstr :reply_text
703
- shortstr :exchange
704
- shortstr :routing_key
682
+ short :reply_code
683
+ shortstr :reply_text
684
+ shortstr :exchange
685
+ shortstr :routing_key
705
686
  end
706
687
 
707
688
  class Deliver
708
- shortstr :consumer_tag
709
- longlong :delivery_tag
710
- shortstr :exchange
711
- shortstr :queue
689
+ shortstr :consumer_tag
690
+ longlong :delivery_tag
691
+ shortstr :exchange
692
+ shortstr :queue
712
693
  end
713
694
 
714
695
  end
@@ -722,6 +703,7 @@ module Bunny
722
703
  class Rollback < Method( 30, :rollback ); end
723
704
  class RollbackOk < Method( 31, :rollback_ok ); end
724
705
 
706
+
725
707
  class Select
726
708
  end
727
709
 
@@ -749,6 +731,7 @@ module Bunny
749
731
  class Start < Method( 20, :start ); end
750
732
  class StartOk < Method( 21, :start_ok ); end
751
733
 
734
+
752
735
  class Select
753
736
  end
754
737
 
@@ -756,7 +739,7 @@ module Bunny
756
739
  end
757
740
 
758
741
  class Start
759
- shortstr :dtx_identifier
742
+ shortstr :dtx_identifier
760
743
  end
761
744
 
762
745
  class StartOk
@@ -773,8 +756,9 @@ module Bunny
773
756
 
774
757
  class Request < Method( 10, :request ); end
775
758
 
759
+
776
760
  class Request
777
- table :meta_data
761
+ table :meta_data
778
762
  end
779
763
 
780
764
  end
@@ -790,47 +774,49 @@ module Bunny
790
774
  class Content < Method( 40, :content ); end
791
775
  class ContentOk < Method( 41, :content_ok ); end
792
776
 
777
+
793
778
  class Integer
794
- octet :integer_1
795
- short :integer_2
796
- long :integer_3
797
- longlong :integer_4
798
- octet :operation
779
+ octet :integer_1
780
+ short :integer_2
781
+ long :integer_3
782
+ longlong :integer_4
783
+ octet :operation
799
784
  end
800
785
 
801
786
  class IntegerOk
802
- longlong :result
787
+ longlong :result
803
788
  end
804
789
 
805
790
  class String
806
- shortstr :string_1
807
- longstr :string_2
808
- octet :operation
791
+ shortstr :string_1
792
+ longstr :string_2
793
+ octet :operation
809
794
  end
810
795
 
811
796
  class StringOk
812
- longstr :result
797
+ longstr :result
813
798
  end
814
799
 
815
800
  class Table
816
- table :table
817
- octet :integer_op
818
- octet :string_op
801
+ table :table
802
+ octet :integer_op
803
+ octet :string_op
819
804
  end
820
805
 
821
806
  class TableOk
822
- longlong :integer_result
823
- longstr :string_result
807
+ longlong :integer_result
808
+ longstr :string_result
824
809
  end
825
810
 
826
811
  class Content
827
812
  end
828
813
 
829
814
  class ContentOk
830
- long :content_checksum
815
+ long :content_checksum
831
816
  end
832
817
 
833
818
  end
834
819
 
835
820
  end
821
+
836
822
  end