amqp 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,135 @@
1
+ require 'rubygems'
2
+ require 'eventmachine'
3
+ require 'amqp/frame'
4
+ require 'pp'
5
+
6
+ module AMQP
7
+ module BasicClient
8
+ def process_frame frame
9
+ if mq = channels[frame.channel]
10
+ mq.process_frame(frame)
11
+ return
12
+ end
13
+
14
+ case frame
15
+ when Frame::Method
16
+ case method = frame.payload
17
+ when Protocol::Connection::Start
18
+ send Protocol::Connection::StartOk.new({:platform => 'Ruby/EventMachine',
19
+ :product => 'AMQP',
20
+ :information => 'http://github.com/tmm1/amqp',
21
+ :version => '0.5.0'},
22
+ 'AMQPLAIN',
23
+ {:LOGIN => 'guest',
24
+ :PASSWORD => 'guest'},
25
+ 'en_US')
26
+
27
+ when Protocol::Connection::Tune
28
+ send Protocol::Connection::TuneOk.new(:channel_max => 0,
29
+ :frame_max => 131072,
30
+ :heartbeat => 0)
31
+
32
+ send Protocol::Connection::Open.new(:virtual_host => '/',
33
+ :capabilities => '',
34
+ :insist => false)
35
+
36
+ when Protocol::Connection::OpenOk
37
+ @dfr.succeed(self)
38
+ end
39
+ end
40
+ end
41
+ end
42
+
43
+ def self.client
44
+ @client ||= BasicClient
45
+ end
46
+
47
+ def self.client= mod
48
+ mod.__send__ :include, AMQP
49
+ @client = mod
50
+ end
51
+
52
+ module Client
53
+ def initialize dfr
54
+ @dfr = dfr
55
+ extend AMQP.client
56
+ end
57
+
58
+ def connection_completed
59
+ log 'connected'
60
+ @buf = Buffer.new
61
+ send_data HEADER
62
+ send_data [1, 1, VERSION_MAJOR, VERSION_MINOR].pack('C4')
63
+ end
64
+
65
+ def add_channel mq
66
+ channels[ key = (channels.keys.max || 0) + 1 ] = mq
67
+ key
68
+ end
69
+
70
+ def channels mq = nil
71
+ @channels ||= {}
72
+ end
73
+
74
+ def receive_data data
75
+ @buf << data
76
+ # log 'receive_data', data
77
+
78
+ while frame = Frame.parse(@buf)
79
+ log 'receive', frame
80
+ process_frame frame
81
+ end
82
+ end
83
+
84
+ def process_frame frame
85
+ # this is a stub meant to be
86
+ # replaced by the module passed into initialize
87
+ end
88
+
89
+ def send data, opts = {}
90
+ channel = opts[:channel] ||= 0
91
+ data = data.to_frame(channel) unless data.is_a? Frame
92
+ data.channel = channel
93
+ log 'send', data
94
+ send_data data.to_s
95
+ end
96
+
97
+ def send_data data
98
+ # log 'send_data', data
99
+ super
100
+ end
101
+
102
+ def unbind
103
+ log 'disconnected'
104
+ end
105
+
106
+ def self.connect opts = {}
107
+ opts[:host] ||= 'localhost'
108
+ opts[:port] ||= PORT
109
+
110
+ dfr = EM::DefaultDeferrable.new
111
+
112
+ EM.run{
113
+ EM.connect opts[:host], opts[:port], self, dfr
114
+ }
115
+
116
+ dfr
117
+ end
118
+
119
+ private
120
+
121
+ def log *args
122
+ return unless AMQP.logging
123
+ pp args
124
+ puts
125
+ end
126
+ end
127
+
128
+ def self.start *args
129
+ @conn ||= Client.connect *args
130
+ end
131
+ end
132
+
133
+ if $0 == __FILE__
134
+ AMQP.start
135
+ end
@@ -0,0 +1,124 @@
1
+ require 'amqp/spec'
2
+ require 'amqp/buffer'
3
+ require 'amqp/protocol'
4
+
5
+ module AMQP
6
+ class Frame
7
+ def initialize payload = nil, channel = 0
8
+ @channel, @payload = channel, payload
9
+ end
10
+ attr_accessor :channel, :payload
11
+
12
+ def id
13
+ self.class::ID
14
+ end
15
+
16
+ def to_binary
17
+ buf = Buffer.new
18
+ buf.write :octet, id
19
+ buf.write :short, channel
20
+ buf.write :longstr, payload
21
+ buf.write :octet, FOOTER
22
+ buf.rewind
23
+ buf
24
+ end
25
+
26
+ def to_s
27
+ to_binary.to_s
28
+ end
29
+
30
+ def == frame
31
+ [ :id, :channel, :payload ].inject(true) do |eql, field|
32
+ eql and __send__(field) == frame.__send__(field)
33
+ end
34
+ end
35
+
36
+ class Invalid < Exception; end
37
+
38
+ class Method
39
+ def initialize payload = nil, channel = 0
40
+ super
41
+ unless @payload.is_a? Protocol::Class::Method or @payload.nil?
42
+ @payload = Protocol.parse(@payload)
43
+ end
44
+ end
45
+ end
46
+
47
+ class Header
48
+ def initialize payload = nil, channel = 0
49
+ super
50
+ unless @payload.is_a? Protocol::Header or @payload.nil?
51
+ @payload = Protocol::Header.new(@payload)
52
+ end
53
+ end
54
+ end
55
+
56
+ class Body; end
57
+
58
+ def self.parse buf
59
+ buf = Buffer.new(buf) unless buf.is_a? Buffer
60
+ buf.extract do
61
+ id, channel, payload, footer = buf.read(:octet, :short, :longstr, :octet)
62
+ Frame.types[id].new(payload, channel) if footer == FOOTER
63
+ end
64
+ end
65
+ end
66
+ end
67
+
68
+ if $0 =~ /bacon/ or $0 == __FILE__
69
+ require 'bacon'
70
+ include AMQP
71
+
72
+ describe Frame do
73
+ should 'handle basic frame types' do
74
+ Frame::Method.new.id.should == 1
75
+ Frame::Header.new.id.should == 2
76
+ Frame::Body.new.id.should == 3
77
+ end
78
+
79
+ should 'convert method frames to binary' do
80
+ meth = Protocol::Connection::Secure.new :challenge => 'secret'
81
+
82
+ frame = Frame::Method.new(meth)
83
+ frame.to_binary.should.be.kind_of? Buffer
84
+ frame.to_s.should == [ 1, 0, meth.to_s.length, meth.to_s, 206 ].pack('CnNa*C')
85
+ end
86
+
87
+ should 'convert binary to method frames' do
88
+ orig = Frame::Method.new Protocol::Connection::Secure.new(:challenge => 'secret')
89
+
90
+ copy = Frame.parse(orig.to_binary)
91
+ copy.should == orig
92
+ end
93
+
94
+ should 'ignore partial frames until ready' do
95
+ frame = Frame::Method.new Protocol::Connection::Secure.new(:challenge => 'secret')
96
+ data = frame.to_s
97
+
98
+ buf = Buffer.new
99
+ Frame.parse(buf).should == nil
100
+
101
+ buf << data[0..5]
102
+ Frame.parse(buf).should == nil
103
+
104
+ buf << data[6..-1]
105
+ Frame.parse(buf).should == frame
106
+
107
+ Frame.parse(buf).should == nil
108
+ end
109
+
110
+ should 'convert header frames to binary' do
111
+ head = Protocol::Header.new(Protocol::Basic, :priority => 1)
112
+
113
+ frame = Frame::Header.new(head)
114
+ frame.to_s.should == [ 2, 0, head.to_s.length, head.to_s, 206 ].pack('CnNa*C')
115
+ end
116
+
117
+ should 'convert binary to header frame' do
118
+ orig = Frame::Header.new Protocol::Header.new(Protocol::Basic, :priority => 1)
119
+
120
+ copy = Frame.parse(orig.to_binary)
121
+ copy.should == orig
122
+ end
123
+ end
124
+ end
@@ -0,0 +1,181 @@
1
+ require 'amqp/spec'
2
+ require 'amqp/buffer'
3
+
4
+ module AMQP
5
+ module Protocol
6
+ class Class::Method
7
+ def initialize *args
8
+ opts = args.pop if args.last.is_a? Hash
9
+ opts ||= {}
10
+
11
+ @debug = 1 # XXX hack, p(obj) == '' if no instance vars are set
12
+
13
+ if args.size == 1 and args.first.is_a? Buffer
14
+ buf = args.shift
15
+ else
16
+ buf = nil
17
+ end
18
+
19
+ self.class.arguments.each do |type, name|
20
+ val = buf ? buf.read(type) :
21
+ args.shift || opts[name] || opts[name.to_s]
22
+ instance_variable_set("@#{name}", val)
23
+ end
24
+ end
25
+
26
+ def to_binary
27
+ buf = Buffer.new
28
+ buf.write :short, self.class.parent.id
29
+ buf.write :short, self.class.id
30
+
31
+ bits = []
32
+
33
+ self.class.arguments.each do |type, name|
34
+ val = instance_variable_get("@#{name}")
35
+ if type == :bit
36
+ bits << (val || false)
37
+ else
38
+ unless bits.empty?
39
+ buf.write :bit, bits
40
+ bits = []
41
+ end
42
+ buf.write type, val
43
+ end
44
+ end
45
+
46
+ buf.write :bit, bits unless bits.empty?
47
+ buf.rewind
48
+
49
+ buf
50
+ end
51
+
52
+ def to_s
53
+ to_binary.to_s
54
+ end
55
+
56
+ def to_frame channel = 0
57
+ Frame::Method.new(self, channel)
58
+ end
59
+ end
60
+
61
+ class Header
62
+ def initialize *args
63
+ opts = args.pop if args.last.is_a? Hash
64
+ opts ||= {}
65
+
66
+ first = args.shift
67
+
68
+ if first.is_a? ::Class and first.ancestors.include? Protocol::Class
69
+ @klass = first
70
+ @size = args.shift || 0
71
+ @weight = args.shift || 0
72
+ @properties = opts
73
+
74
+ elsif first.is_a? Buffer or first.is_a? String
75
+ buf = first
76
+ buf = Buffer.new(buf) unless buf.is_a? Buffer
77
+
78
+ @klass = Protocol.classes[buf.read(:short)]
79
+ @weight = buf.read(:short)
80
+ @size = buf.read(:longlong)
81
+
82
+ props = buf.read(:properties, *klass.properties.map{|type,_| type })
83
+ @properties = Hash[*klass.properties.map{|_,name| name }.zip(props).reject{|k,v| v.nil? }.flatten]
84
+
85
+ else
86
+ raise ArgumentError, 'Invalid argument'
87
+ end
88
+
89
+ end
90
+ attr_accessor :klass, :size, :weight, :properties
91
+
92
+ def to_binary
93
+ buf = Buffer.new
94
+ buf.write :short, klass.id
95
+ buf.write :short, weight # XXX rabbitmq only supports weight == 0
96
+ buf.write :longlong, size
97
+ buf.write :properties, (klass.properties.map do |type, name|
98
+ [ type, properties[name] || properties[name.to_s] ]
99
+ end)
100
+ buf.rewind
101
+ buf
102
+ end
103
+
104
+ def to_s
105
+ to_binary.to_s
106
+ end
107
+
108
+ def to_frame channel = 0
109
+ Frame::Header.new(self, channel)
110
+ end
111
+
112
+ def == header
113
+ [ :klass, :size, :weight, :properties ].inject(true) do |eql, field|
114
+ eql and __send__(field) == header.__send__(field)
115
+ end
116
+ end
117
+
118
+ def method_missing meth, *args, &blk
119
+ @klass.properties.map{|_,name| name }.include?(meth) ? @properties[meth] :
120
+ super
121
+ end
122
+ end
123
+
124
+ def self.parse buf
125
+ buf = Buffer.new(buf) unless buf.is_a? Buffer
126
+ class_id, method_id = buf.read(:short, :short)
127
+ classes[class_id].methods[method_id].new(buf)
128
+ end
129
+ end
130
+ end
131
+
132
+ if $0 =~ /bacon/ or $0 == __FILE__
133
+ require 'bacon'
134
+ include AMQP
135
+
136
+ describe Protocol do
137
+ should 'instantiate methods with arguments' do
138
+ meth = Protocol::Connection::StartOk.new nil, 'PLAIN', nil, 'en_US'
139
+ meth.locale.should == 'en_US'
140
+ end
141
+
142
+ should 'instantiate methods with named parameters' do
143
+ meth = Protocol::Connection::StartOk.new :locale => 'en_US',
144
+ :mechanism => 'PLAIN'
145
+ meth.locale.should == 'en_US'
146
+ end
147
+
148
+ should 'convert methods to binary' do
149
+ meth = Protocol::Connection::Secure.new :challenge => 'secret'
150
+ meth.to_binary.should.be.kind_of? Buffer
151
+
152
+ meth.to_s.should == [ 10, 20, 6, 'secret' ].pack('nnNa*')
153
+ end
154
+
155
+ should 'convert binary to method' do
156
+ orig = Protocol::Connection::Secure.new :challenge => 'secret'
157
+ copy = Protocol.parse orig.to_binary
158
+ orig.should == copy
159
+ end
160
+
161
+ should 'convert headers to binary' do
162
+ head = Protocol::Header.new Protocol::Basic,
163
+ size = 5,
164
+ weight = 0,
165
+ :content_type => 'text/json',
166
+ :delivery_mode => 1,
167
+ :priority => 1
168
+ head.to_s.should == [ 60, weight, 0, size, 0b1001_1000_0000_0000, 9, 'text/json', 1, 1 ].pack('nnNNnCa*CC')
169
+ end
170
+
171
+ should 'convert binary to header' do
172
+ orig = Protocol::Header.new Protocol::Basic,
173
+ size = 5,
174
+ weight = 0,
175
+ :content_type => 'text/json',
176
+ :delivery_mode => 1,
177
+ :priority => 1
178
+ Protocol::Header.new(orig.to_binary).should == orig
179
+ end
180
+ end
181
+ end
@@ -0,0 +1,813 @@
1
+
2
+ module AMQP
3
+ HEADER = "AMQP".freeze
4
+ VERSION_MAJOR = 8
5
+ VERSION_MINOR = 0
6
+ PORT = 5672
7
+
8
+ class Frame
9
+ def self.types
10
+ @types ||= {}
11
+ end
12
+
13
+ def self.Frame id
14
+ (@_base_frames ||= {})[id] ||= Class.new(Frame) do
15
+ class_eval %[
16
+ def self.inherited klass
17
+ klass.const_set(:ID, #{id})
18
+ Frame.types[#{id}] = klass
19
+ end
20
+ ]
21
+ end
22
+ end
23
+
24
+ class Method < Frame( 1 ); end
25
+ class Header < Frame( 2 ); end
26
+ class Body < Frame( 3 ); end
27
+ class OobMethod < Frame( 4 ); end
28
+ class OobHeader < Frame( 5 ); end
29
+ class OobBody < Frame( 6 ); end
30
+ class Trace < Frame( 7 ); end
31
+ class Heartbeat < Frame( 8 ); end
32
+
33
+ FOOTER = 206
34
+ end
35
+
36
+ RESPONSES = {
37
+ 200 => :REPLY_SUCCESS,
38
+ 310 => :NOT_DELIVERED,
39
+ 311 => :CONTENT_TOO_LARGE,
40
+ 312 => :NO_ROUTE,
41
+ 313 => :NO_CONSUMERS,
42
+ 403 => :ACCESS_REFUSED,
43
+ 404 => :NOT_FOUND,
44
+ 405 => :RESOURCE_LOCKED,
45
+ 406 => :PRECONDITION_FAILED,
46
+ 320 => :CONNECTION_FORCED,
47
+ 402 => :INVALID_PATH,
48
+ }
49
+
50
+ FIELDS = [
51
+ :bit,
52
+ :long,
53
+ :longlong,
54
+ :longstr,
55
+ :octet,
56
+ :short,
57
+ :shortstr,
58
+ :table,
59
+ :timestamp,
60
+ ]
61
+
62
+ module Protocol
63
+ class Class
64
+ class << self
65
+ FIELDS.each do |f|
66
+ class_eval %[
67
+ def #{f} name
68
+ properties << [ :#{f}, name ] unless properties.include?([:#{f}, name])
69
+ attr_accessor name
70
+ end
71
+ ]
72
+ end
73
+
74
+ def properties() @properties ||= [] end
75
+
76
+ def id() self::ID end
77
+ def name() self::NAME end
78
+ end
79
+
80
+ class Method
81
+ class << self
82
+ FIELDS.each do |f|
83
+ class_eval %[
84
+ def #{f} name
85
+ arguments << [ :#{f}, name ] unless arguments.include?([:#{f}, name])
86
+ attr_accessor name
87
+ end
88
+ ]
89
+ end
90
+
91
+ def arguments() @arguments ||= [] end
92
+
93
+ def parent() Protocol.const_get(self.to_s[/Protocol::(.+?)::/,1]) end
94
+ def id() self::ID end
95
+ def name() self::NAME end
96
+ end
97
+
98
+ def == b
99
+ self.class.arguments.inject(true) do |eql, (type, name)|
100
+ eql and __send__("#{name}") == b.__send__("#{name}")
101
+ end
102
+ end
103
+ end
104
+
105
+ def self.methods() @methods ||= {} end
106
+
107
+ def self.Method(id, name)
108
+ @_base_methods ||= {}
109
+ @_base_methods[id] ||= ::Class.new(Method) do
110
+ class_eval %[
111
+ def self.inherited klass
112
+ klass.const_set(:ID, #{id})
113
+ klass.const_set(:NAME, :#{name.to_s})
114
+ klass.parent.methods[#{id}] = klass
115
+ klass.parent.methods[klass::NAME] = klass
116
+ end
117
+ ]
118
+ end
119
+ end
120
+ end
121
+
122
+ def self.classes() @classes ||= {} end
123
+
124
+ def self.Class(id, name)
125
+ @_base_classes ||= {}
126
+ @_base_classes[id] ||= ::Class.new(Class) do
127
+ class_eval %[
128
+ def self.inherited klass
129
+ klass.const_set(:ID, #{id})
130
+ klass.const_set(:NAME, :#{name.to_s})
131
+ Protocol.classes[#{id}] = klass
132
+ Protocol.classes[klass::NAME] = klass
133
+ end
134
+ ]
135
+ end
136
+ end
137
+ end
138
+ end
139
+
140
+ module AMQP
141
+ module Protocol
142
+ class Connection < Class( 10, :connection ); end
143
+ class Channel < Class( 20, :channel ); end
144
+ class Access < Class( 30, :access ); end
145
+ class Exchange < Class( 40, :exchange ); end
146
+ class Queue < Class( 50, :queue ); end
147
+ class Basic < Class( 60, :basic ); end
148
+ class File < Class( 70, :file ); end
149
+ class Stream < Class( 80, :stream ); end
150
+ class Tx < Class( 90, :tx ); end
151
+ class Dtx < Class( 100, :dtx ); end
152
+ class Tunnel < Class( 110, :tunnel ); end
153
+ class Test < Class( 120, :test ); end
154
+
155
+ class Connection
156
+
157
+ class Start < Method( 10, :start ); end
158
+ class StartOk < Method( 11, :start_ok ); end
159
+ class Secure < Method( 20, :secure ); end
160
+ class SecureOk < Method( 21, :secure_ok ); end
161
+ class Tune < Method( 30, :tune ); end
162
+ class TuneOk < Method( 31, :tune_ok ); end
163
+ class Open < Method( 40, :open ); end
164
+ class OpenOk < Method( 41, :open_ok ); end
165
+ class Redirect < Method( 50, :redirect ); end
166
+ class Close < Method( 60, :close ); end
167
+ class CloseOk < Method( 61, :close_ok ); end
168
+
169
+ class Start
170
+ octet :version_major
171
+ octet :version_minor
172
+ table :server_properties
173
+ longstr :mechanisms
174
+ longstr :locales
175
+ end
176
+
177
+ class StartOk
178
+ table :client_properties
179
+ shortstr :mechanism
180
+ longstr :response
181
+ shortstr :locale
182
+ end
183
+
184
+ class Secure
185
+ longstr :challenge
186
+ end
187
+
188
+ class SecureOk
189
+ longstr :response
190
+ end
191
+
192
+ class Tune
193
+ short :channel_max
194
+ long :frame_max
195
+ short :heartbeat
196
+ end
197
+
198
+ class TuneOk
199
+ short :channel_max
200
+ long :frame_max
201
+ short :heartbeat
202
+ end
203
+
204
+ class Open
205
+ shortstr :virtual_host
206
+ shortstr :capabilities
207
+ bit :insist
208
+ end
209
+
210
+ class OpenOk
211
+ shortstr :known_hosts
212
+ end
213
+
214
+ class Redirect
215
+ shortstr :host
216
+ shortstr :known_hosts
217
+ end
218
+
219
+ class Close
220
+ short :reply_code
221
+ shortstr :reply_text
222
+ short :class_id
223
+ short :method_id
224
+ end
225
+
226
+ class CloseOk
227
+ end
228
+
229
+ end
230
+
231
+ class Channel
232
+
233
+ class Open < Method( 10, :open ); end
234
+ class OpenOk < Method( 11, :open_ok ); end
235
+ class Flow < Method( 20, :flow ); end
236
+ class FlowOk < Method( 21, :flow_ok ); end
237
+ class Alert < Method( 30, :alert ); end
238
+ class Close < Method( 40, :close ); end
239
+ class CloseOk < Method( 41, :close_ok ); end
240
+
241
+ class Open
242
+ shortstr :out_of_band
243
+ end
244
+
245
+ class OpenOk
246
+ end
247
+
248
+ class Flow
249
+ bit :active
250
+ end
251
+
252
+ class FlowOk
253
+ bit :active
254
+ end
255
+
256
+ class Alert
257
+ short :reply_code
258
+ shortstr :reply_text
259
+ table :details
260
+ end
261
+
262
+ class Close
263
+ short :reply_code
264
+ shortstr :reply_text
265
+ short :class_id
266
+ short :method_id
267
+ end
268
+
269
+ class CloseOk
270
+ end
271
+
272
+ end
273
+
274
+ class Access
275
+
276
+ class Request < Method( 10, :request ); end
277
+ class RequestOk < Method( 11, :request_ok ); end
278
+
279
+ class Request
280
+ shortstr :realm
281
+ bit :exclusive
282
+ bit :passive
283
+ bit :active
284
+ bit :write
285
+ bit :read
286
+ end
287
+
288
+ class RequestOk
289
+ short :ticket
290
+ end
291
+
292
+ end
293
+
294
+ class Exchange
295
+
296
+ class Declare < Method( 10, :declare ); end
297
+ class DeclareOk < Method( 11, :declare_ok ); end
298
+ class Delete < Method( 20, :delete ); end
299
+ class DeleteOk < Method( 21, :delete_ok ); end
300
+
301
+ class Declare
302
+ short :ticket
303
+ shortstr :exchange
304
+ shortstr :type
305
+ bit :passive
306
+ bit :durable
307
+ bit :auto_delete
308
+ bit :internal
309
+ bit :nowait
310
+ table :arguments
311
+ end
312
+
313
+ class DeclareOk
314
+ end
315
+
316
+ class Delete
317
+ short :ticket
318
+ shortstr :exchange
319
+ bit :if_unused
320
+ bit :nowait
321
+ end
322
+
323
+ class DeleteOk
324
+ end
325
+
326
+ end
327
+
328
+ class Queue
329
+
330
+ class Declare < Method( 10, :declare ); end
331
+ class DeclareOk < Method( 11, :declare_ok ); end
332
+ class Bind < Method( 20, :bind ); end
333
+ class BindOk < Method( 21, :bind_ok ); end
334
+ class Purge < Method( 30, :purge ); end
335
+ class PurgeOk < Method( 31, :purge_ok ); end
336
+ class Delete < Method( 40, :delete ); end
337
+ class DeleteOk < Method( 41, :delete_ok ); end
338
+
339
+ class Declare
340
+ short :ticket
341
+ shortstr :queue
342
+ bit :passive
343
+ bit :durable
344
+ bit :exclusive
345
+ bit :auto_delete
346
+ bit :nowait
347
+ table :arguments
348
+ end
349
+
350
+ class DeclareOk
351
+ shortstr :queue
352
+ long :message_count
353
+ long :consumer_count
354
+ end
355
+
356
+ class Bind
357
+ short :ticket
358
+ shortstr :queue
359
+ shortstr :exchange
360
+ shortstr :routing_key
361
+ bit :nowait
362
+ table :arguments
363
+ end
364
+
365
+ class BindOk
366
+ end
367
+
368
+ class Purge
369
+ short :ticket
370
+ shortstr :queue
371
+ bit :nowait
372
+ end
373
+
374
+ class PurgeOk
375
+ long :message_count
376
+ end
377
+
378
+ class Delete
379
+ short :ticket
380
+ shortstr :queue
381
+ bit :if_unused
382
+ bit :if_empty
383
+ bit :nowait
384
+ end
385
+
386
+ class DeleteOk
387
+ long :message_count
388
+ end
389
+
390
+ end
391
+
392
+ class Basic
393
+ shortstr :content_type
394
+ shortstr :content_encoding
395
+ table :headers
396
+ octet :delivery_mode
397
+ octet :priority
398
+ shortstr :correlation_id
399
+ shortstr :reply_to
400
+ shortstr :expiration
401
+ shortstr :message_id
402
+ timestamp :timestamp
403
+ shortstr :type
404
+ shortstr :user_id
405
+ shortstr :app_id
406
+ shortstr :cluster_id
407
+
408
+ class Qos < Method( 10, :qos ); end
409
+ class QosOk < Method( 11, :qos_ok ); end
410
+ class Consume < Method( 20, :consume ); end
411
+ class ConsumeOk < Method( 21, :consume_ok ); end
412
+ class Cancel < Method( 30, :cancel ); end
413
+ class CancelOk < Method( 31, :cancel_ok ); end
414
+ class Publish < Method( 40, :publish ); end
415
+ class Return < Method( 50, :return ); end
416
+ class Deliver < Method( 60, :deliver ); end
417
+ class Get < Method( 70, :get ); end
418
+ class GetOk < Method( 71, :get_ok ); end
419
+ class GetEmpty < Method( 72, :get_empty ); end
420
+ class Ack < Method( 80, :ack ); end
421
+ class Reject < Method( 90, :reject ); end
422
+ class Recover < Method( 100, :recover ); end
423
+
424
+ class Qos
425
+ long :prefetch_size
426
+ short :prefetch_count
427
+ bit :global
428
+ end
429
+
430
+ class QosOk
431
+ end
432
+
433
+ class Consume
434
+ short :ticket
435
+ shortstr :queue
436
+ shortstr :consumer_tag
437
+ bit :no_local
438
+ bit :no_ack
439
+ bit :exclusive
440
+ bit :nowait
441
+ end
442
+
443
+ class ConsumeOk
444
+ shortstr :consumer_tag
445
+ end
446
+
447
+ class Cancel
448
+ shortstr :consumer_tag
449
+ bit :nowait
450
+ end
451
+
452
+ class CancelOk
453
+ shortstr :consumer_tag
454
+ end
455
+
456
+ class Publish
457
+ short :ticket
458
+ shortstr :exchange
459
+ shortstr :routing_key
460
+ bit :mandatory
461
+ bit :immediate
462
+ end
463
+
464
+ class Return
465
+ short :reply_code
466
+ shortstr :reply_text
467
+ shortstr :exchange
468
+ shortstr :routing_key
469
+ end
470
+
471
+ class Deliver
472
+ shortstr :consumer_tag
473
+ longlong :delivery_tag
474
+ bit :redelivered
475
+ shortstr :exchange
476
+ shortstr :routing_key
477
+ end
478
+
479
+ class Get
480
+ short :ticket
481
+ shortstr :queue
482
+ bit :no_ack
483
+ end
484
+
485
+ class GetOk
486
+ longlong :delivery_tag
487
+ bit :redelivered
488
+ shortstr :exchange
489
+ shortstr :routing_key
490
+ long :message_count
491
+ end
492
+
493
+ class GetEmpty
494
+ shortstr :cluster_id
495
+ end
496
+
497
+ class Ack
498
+ longlong :delivery_tag
499
+ bit :multiple
500
+ end
501
+
502
+ class Reject
503
+ longlong :delivery_tag
504
+ bit :requeue
505
+ end
506
+
507
+ class Recover
508
+ bit :requeue
509
+ end
510
+
511
+ end
512
+
513
+ class File
514
+ shortstr :content_type
515
+ shortstr :content_encoding
516
+ table :headers
517
+ octet :priority
518
+ shortstr :reply_to
519
+ shortstr :message_id
520
+ shortstr :filename
521
+ timestamp :timestamp
522
+ shortstr :cluster_id
523
+
524
+ class Qos < Method( 10, :qos ); end
525
+ class QosOk < Method( 11, :qos_ok ); end
526
+ class Consume < Method( 20, :consume ); end
527
+ class ConsumeOk < Method( 21, :consume_ok ); end
528
+ class Cancel < Method( 30, :cancel ); end
529
+ class CancelOk < Method( 31, :cancel_ok ); end
530
+ class Open < Method( 40, :open ); end
531
+ class OpenOk < Method( 41, :open_ok ); end
532
+ class Stage < Method( 50, :stage ); end
533
+ class Publish < Method( 60, :publish ); end
534
+ class Return < Method( 70, :return ); end
535
+ class Deliver < Method( 80, :deliver ); end
536
+ class Ack < Method( 90, :ack ); end
537
+ class Reject < Method( 100, :reject ); end
538
+
539
+ class Qos
540
+ long :prefetch_size
541
+ short :prefetch_count
542
+ bit :global
543
+ end
544
+
545
+ class QosOk
546
+ end
547
+
548
+ class Consume
549
+ short :ticket
550
+ shortstr :queue
551
+ shortstr :consumer_tag
552
+ bit :no_local
553
+ bit :no_ack
554
+ bit :exclusive
555
+ bit :nowait
556
+ end
557
+
558
+ class ConsumeOk
559
+ shortstr :consumer_tag
560
+ end
561
+
562
+ class Cancel
563
+ shortstr :consumer_tag
564
+ bit :nowait
565
+ end
566
+
567
+ class CancelOk
568
+ shortstr :consumer_tag
569
+ end
570
+
571
+ class Open
572
+ shortstr :identifier
573
+ longlong :content_size
574
+ end
575
+
576
+ class OpenOk
577
+ longlong :staged_size
578
+ end
579
+
580
+ class Stage
581
+ end
582
+
583
+ class Publish
584
+ short :ticket
585
+ shortstr :exchange
586
+ shortstr :routing_key
587
+ bit :mandatory
588
+ bit :immediate
589
+ shortstr :identifier
590
+ end
591
+
592
+ class Return
593
+ short :reply_code
594
+ shortstr :reply_text
595
+ shortstr :exchange
596
+ shortstr :routing_key
597
+ end
598
+
599
+ class Deliver
600
+ shortstr :consumer_tag
601
+ longlong :delivery_tag
602
+ bit :redelivered
603
+ shortstr :exchange
604
+ shortstr :routing_key
605
+ shortstr :identifier
606
+ end
607
+
608
+ class Ack
609
+ longlong :delivery_tag
610
+ bit :multiple
611
+ end
612
+
613
+ class Reject
614
+ longlong :delivery_tag
615
+ bit :requeue
616
+ end
617
+
618
+ end
619
+
620
+ class Stream
621
+ shortstr :content_type
622
+ shortstr :content_encoding
623
+ table :headers
624
+ octet :priority
625
+ timestamp :timestamp
626
+
627
+ class Qos < Method( 10, :qos ); end
628
+ class QosOk < Method( 11, :qos_ok ); end
629
+ class Consume < Method( 20, :consume ); end
630
+ class ConsumeOk < Method( 21, :consume_ok ); end
631
+ class Cancel < Method( 30, :cancel ); end
632
+ class CancelOk < Method( 31, :cancel_ok ); end
633
+ class Publish < Method( 40, :publish ); end
634
+ class Return < Method( 50, :return ); end
635
+ class Deliver < Method( 60, :deliver ); end
636
+
637
+ class Qos
638
+ long :prefetch_size
639
+ short :prefetch_count
640
+ long :consume_rate
641
+ bit :global
642
+ end
643
+
644
+ class QosOk
645
+ end
646
+
647
+ class Consume
648
+ short :ticket
649
+ shortstr :queue
650
+ shortstr :consumer_tag
651
+ bit :no_local
652
+ bit :exclusive
653
+ bit :nowait
654
+ end
655
+
656
+ class ConsumeOk
657
+ shortstr :consumer_tag
658
+ end
659
+
660
+ class Cancel
661
+ shortstr :consumer_tag
662
+ bit :nowait
663
+ end
664
+
665
+ class CancelOk
666
+ shortstr :consumer_tag
667
+ end
668
+
669
+ class Publish
670
+ short :ticket
671
+ shortstr :exchange
672
+ shortstr :routing_key
673
+ bit :mandatory
674
+ bit :immediate
675
+ end
676
+
677
+ class Return
678
+ short :reply_code
679
+ shortstr :reply_text
680
+ shortstr :exchange
681
+ shortstr :routing_key
682
+ end
683
+
684
+ class Deliver
685
+ shortstr :consumer_tag
686
+ longlong :delivery_tag
687
+ shortstr :exchange
688
+ shortstr :queue
689
+ end
690
+
691
+ end
692
+
693
+ class Tx
694
+
695
+ class Select < Method( 10, :select ); end
696
+ class SelectOk < Method( 11, :select_ok ); end
697
+ class Commit < Method( 20, :commit ); end
698
+ class CommitOk < Method( 21, :commit_ok ); end
699
+ class Rollback < Method( 30, :rollback ); end
700
+ class RollbackOk < Method( 31, :rollback_ok ); end
701
+
702
+ class Select
703
+ end
704
+
705
+ class SelectOk
706
+ end
707
+
708
+ class Commit
709
+ end
710
+
711
+ class CommitOk
712
+ end
713
+
714
+ class Rollback
715
+ end
716
+
717
+ class RollbackOk
718
+ end
719
+
720
+ end
721
+
722
+ class Dtx
723
+
724
+ class Select < Method( 10, :select ); end
725
+ class SelectOk < Method( 11, :select_ok ); end
726
+ class Start < Method( 20, :start ); end
727
+ class StartOk < Method( 21, :start_ok ); end
728
+
729
+ class Select
730
+ end
731
+
732
+ class SelectOk
733
+ end
734
+
735
+ class Start
736
+ shortstr :dtx_identifier
737
+ end
738
+
739
+ class StartOk
740
+ end
741
+
742
+ end
743
+
744
+ class Tunnel
745
+ table :headers
746
+ shortstr :proxy_name
747
+ shortstr :data_name
748
+ octet :durable
749
+ octet :broadcast
750
+
751
+ class Request < Method( 10, :request ); end
752
+
753
+ class Request
754
+ table :meta_data
755
+ end
756
+
757
+ end
758
+
759
+ class Test
760
+
761
+ class Integer < Method( 10, :integer ); end
762
+ class IntegerOk < Method( 11, :integer_ok ); end
763
+ class String < Method( 20, :string ); end
764
+ class StringOk < Method( 21, :string_ok ); end
765
+ class Table < Method( 30, :table ); end
766
+ class TableOk < Method( 31, :table_ok ); end
767
+ class Content < Method( 40, :content ); end
768
+ class ContentOk < Method( 41, :content_ok ); end
769
+
770
+ class Integer
771
+ octet :integer_1
772
+ short :integer_2
773
+ long :integer_3
774
+ longlong :integer_4
775
+ octet :operation
776
+ end
777
+
778
+ class IntegerOk
779
+ longlong :result
780
+ end
781
+
782
+ class String
783
+ shortstr :string_1
784
+ longstr :string_2
785
+ octet :operation
786
+ end
787
+
788
+ class StringOk
789
+ longstr :result
790
+ end
791
+
792
+ class Table
793
+ table :table
794
+ octet :integer_op
795
+ octet :string_op
796
+ end
797
+
798
+ class TableOk
799
+ longlong :integer_result
800
+ longstr :string_result
801
+ end
802
+
803
+ class Content
804
+ end
805
+
806
+ class ContentOk
807
+ long :content_checksum
808
+ end
809
+
810
+ end
811
+
812
+ end
813
+ end