tmm1-amqp 0.5.1

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