amq-protocol 0.0.1.pre → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -1
- data/.travis.yml +7 -0
- data/CONTRIBUTORS +2 -0
- data/Gemfile +16 -0
- data/Gemfile.lock +31 -0
- data/LICENSE +1 -1
- data/PROFILING.md +81 -0
- data/README.textile +34 -17
- data/TODO.todo +24 -0
- data/__init__.py +0 -0
- data/amq-protocol.gemspec +16 -11
- data/amqp_0.9.1_changes.json +1 -1
- data/bin/jenkins.sh +23 -0
- data/codegen.py +50 -16
- data/codegen_helpers.py +81 -26
- data/examples/00_manual_test.rb +117 -38
- data/irb.rb +76 -4
- data/lib/amq/hacks.rb +33 -0
- data/lib/amq/protocol.rb +3 -1472
- data/lib/amq/protocol/client.rb +2230 -0
- data/lib/amq/protocol/frame.rb +111 -38
- data/lib/amq/protocol/table.rb +89 -42
- data/lib/amq/protocol/version.rb +5 -0
- data/post-processing.rb +1 -0
- data/protocol.rb.pytemplate +217 -63
- data/spec/amq/hacks_spec.rb +39 -0
- data/spec/amq/protocol/basic_spec.rb +320 -0
- data/spec/amq/protocol/channel_spec.rb +117 -0
- data/spec/amq/protocol/confirm_spec.rb +44 -0
- data/spec/amq/protocol/connection_spec.rb +149 -0
- data/spec/amq/protocol/exchange_spec.rb +95 -0
- data/spec/amq/protocol/frame_spec.rb +93 -78
- data/spec/amq/protocol/method_spec.rb +40 -0
- data/spec/amq/protocol/queue_spec.rb +129 -0
- data/spec/amq/protocol/table_spec.rb +59 -36
- data/spec/amq/protocol/tx_spec.rb +58 -0
- data/spec/amq/protocol_spec.rb +572 -643
- data/spec/spec_helper.rb +25 -2
- data/tasks.rb +13 -8
- metadata +44 -25
- data/amq-protocol.pre.gemspec +0 -6
- data/examples/01_basics.rb +0 -14
- data/examples/02_eventmachine.rb +0 -4
@@ -0,0 +1,2230 @@
|
|
1
|
+
# encoding: binary
|
2
|
+
|
3
|
+
# THIS IS AN AUTOGENERATED FILE, DO NOT MODIFY
|
4
|
+
# IT DIRECTLY ! FOR CHANGES, PLEASE UPDATE CODEGEN.PY
|
5
|
+
# IN THE ROOT DIRECTORY OF THE AMQ-PROTOCOL REPOSITORY.
|
6
|
+
|
7
|
+
require "amq/protocol/table"
|
8
|
+
require "amq/protocol/frame"
|
9
|
+
require "amq/hacks"
|
10
|
+
|
11
|
+
module AMQ
|
12
|
+
module Protocol
|
13
|
+
PROTOCOL_VERSION = "0.9.1".freeze
|
14
|
+
PREAMBLE = "AMQP\x00\x00\x09\x01".freeze
|
15
|
+
DEFAULT_PORT = 5672
|
16
|
+
|
17
|
+
# caching
|
18
|
+
EMPTY_STRING = "".freeze
|
19
|
+
|
20
|
+
PACK_CHAR = "c".freeze
|
21
|
+
PACK_UINT16 = "n".freeze
|
22
|
+
PACK_UINT16_X2 = "n2".freeze
|
23
|
+
PACK_UINT32 = "N".freeze
|
24
|
+
PACK_UINT32_X2 = "N2".freeze
|
25
|
+
PACK_INT64 = "q".freeze
|
26
|
+
PACK_UCHAR_UINT32 = "CN".freeze
|
27
|
+
PACK_CHAR_UINT16_UINT32 = "cnN".freeze
|
28
|
+
|
29
|
+
# @version 0.0.1
|
30
|
+
# @return [Array] Collection of subclasses of AMQ::Protocol::Class.
|
31
|
+
def self.classes
|
32
|
+
Protocol::Class.classes
|
33
|
+
end
|
34
|
+
|
35
|
+
# @version 0.0.1
|
36
|
+
# @return [Array] Collection of subclasses of AMQ::Protocol::Method.
|
37
|
+
def self.methods
|
38
|
+
Protocol::Method.methods
|
39
|
+
end
|
40
|
+
|
41
|
+
class Error < StandardError
|
42
|
+
DEFAULT_MESSAGE = "AMQP error".freeze
|
43
|
+
|
44
|
+
def self.inherited(subclass)
|
45
|
+
@_subclasses ||= []
|
46
|
+
@_subclasses << subclass
|
47
|
+
end # self.inherited(subclazz)
|
48
|
+
|
49
|
+
def self.subclasses_with_values
|
50
|
+
@_subclasses.select{ |k| defined?(k::VALUE) }
|
51
|
+
end # self.subclasses_with_values
|
52
|
+
|
53
|
+
def self.[](code) # TODO: rewrite more effectively
|
54
|
+
if result = subclasses_with_values.detect { |klass| klass::VALUE == code }
|
55
|
+
result
|
56
|
+
else
|
57
|
+
raise "No such exception class for code #{code}" unless result
|
58
|
+
end # if
|
59
|
+
end # self.[]
|
60
|
+
|
61
|
+
def initialize(message = self.class::DEFAULT_MESSAGE)
|
62
|
+
super(message)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
class FrameTypeError < Protocol::Error
|
67
|
+
def initialize(types)
|
68
|
+
super("Must be one of #{types.inspect}")
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
class EmptyResponseError < Protocol::Error
|
73
|
+
DEFAULT_MESSAGE = "Empty response received from the server."
|
74
|
+
|
75
|
+
def initialize(message = self.class::DEFAULT_MESSAGE)
|
76
|
+
super(message)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
class BadResponseError < Protocol::Error
|
81
|
+
def initialize(argument, expected, actual)
|
82
|
+
super("Argument #{argument} has to be #{expected.inspect}, was #{data.inspect}")
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
class SoftError < Protocol::Error
|
87
|
+
def self.inherited(subclass)
|
88
|
+
Error.inherited(subclass)
|
89
|
+
end # self.inherited(subclass)
|
90
|
+
end
|
91
|
+
|
92
|
+
class HardError < Protocol::Error
|
93
|
+
def self.inherited(subclass)
|
94
|
+
Error.inherited(subclass)
|
95
|
+
end # self.inherited(subclass)
|
96
|
+
end
|
97
|
+
|
98
|
+
class ContentTooLarge < SoftError
|
99
|
+
VALUE = 311
|
100
|
+
end
|
101
|
+
|
102
|
+
class NoRoute < SoftError
|
103
|
+
VALUE = 312
|
104
|
+
end
|
105
|
+
|
106
|
+
class NoConsumers < SoftError
|
107
|
+
VALUE = 313
|
108
|
+
end
|
109
|
+
|
110
|
+
class AccessRefused < SoftError
|
111
|
+
VALUE = 403
|
112
|
+
end
|
113
|
+
|
114
|
+
class NotFound < SoftError
|
115
|
+
VALUE = 404
|
116
|
+
end
|
117
|
+
|
118
|
+
class ResourceLocked < SoftError
|
119
|
+
VALUE = 405
|
120
|
+
end
|
121
|
+
|
122
|
+
class PreconditionFailed < SoftError
|
123
|
+
VALUE = 406
|
124
|
+
end
|
125
|
+
|
126
|
+
class ConnectionForced < HardError
|
127
|
+
VALUE = 320
|
128
|
+
end
|
129
|
+
|
130
|
+
class InvalidPath < HardError
|
131
|
+
VALUE = 402
|
132
|
+
end
|
133
|
+
|
134
|
+
class FrameError < HardError
|
135
|
+
VALUE = 501
|
136
|
+
end
|
137
|
+
|
138
|
+
class SyntaxError < HardError
|
139
|
+
VALUE = 502
|
140
|
+
end
|
141
|
+
|
142
|
+
class CommandInvalid < HardError
|
143
|
+
VALUE = 503
|
144
|
+
end
|
145
|
+
|
146
|
+
class ChannelError < HardError
|
147
|
+
VALUE = 504
|
148
|
+
end
|
149
|
+
|
150
|
+
class UnexpectedFrame < HardError
|
151
|
+
VALUE = 505
|
152
|
+
end
|
153
|
+
|
154
|
+
class ResourceError < HardError
|
155
|
+
VALUE = 506
|
156
|
+
end
|
157
|
+
|
158
|
+
class NotAllowed < HardError
|
159
|
+
VALUE = 530
|
160
|
+
end
|
161
|
+
|
162
|
+
class NotImplemented < HardError
|
163
|
+
VALUE = 540
|
164
|
+
end
|
165
|
+
|
166
|
+
class InternalError < HardError
|
167
|
+
VALUE = 541
|
168
|
+
end
|
169
|
+
|
170
|
+
# We don"t instantiate the following classes,
|
171
|
+
# as we don"t actually need any per-instance state.
|
172
|
+
# Also, this is pretty low-level functionality,
|
173
|
+
# hence it should have a reasonable performance.
|
174
|
+
# As everyone knows, garbage collector in MRI performs
|
175
|
+
# really badly, which is another good reason for
|
176
|
+
# not creating any objects, but only use class as
|
177
|
+
# a struct. Creating classes is quite expensive though,
|
178
|
+
# but here the inheritance comes handy and mainly
|
179
|
+
# as we can"t simply make a reference to a function,
|
180
|
+
# we can"t use a hash or an object. I"ve been also
|
181
|
+
# considering to have just a bunch of methods, but
|
182
|
+
# here"s the problem, that after we"d require this file,
|
183
|
+
# all these methods would become global which would
|
184
|
+
# be a bad, bad thing to do.
|
185
|
+
class Class
|
186
|
+
@classes = Array.new
|
187
|
+
|
188
|
+
def self.method_id
|
189
|
+
@method_id
|
190
|
+
end
|
191
|
+
|
192
|
+
def self.name
|
193
|
+
@name
|
194
|
+
end
|
195
|
+
|
196
|
+
def self.inherited(base)
|
197
|
+
if self == Protocol::Class
|
198
|
+
@classes << base
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
def self.classes
|
203
|
+
@classes
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
class Method
|
208
|
+
@methods = Array.new
|
209
|
+
def self.method_id
|
210
|
+
@method_id
|
211
|
+
end
|
212
|
+
|
213
|
+
def self.name
|
214
|
+
@name
|
215
|
+
end
|
216
|
+
|
217
|
+
def self.index
|
218
|
+
@index
|
219
|
+
end
|
220
|
+
|
221
|
+
def self.inherited(base)
|
222
|
+
if self == Protocol::Method
|
223
|
+
@methods << base
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
def self.methods
|
228
|
+
@methods
|
229
|
+
end
|
230
|
+
|
231
|
+
def self.split_headers(user_headers)
|
232
|
+
properties, headers = {}, {}
|
233
|
+
user_headers.each do |key, value|
|
234
|
+
# key MUST be a symbol since symbols are not garbage-collected
|
235
|
+
if Basic::PROPERTIES.include?(key)
|
236
|
+
properties[key] = value
|
237
|
+
else
|
238
|
+
headers[key] = value
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
return [properties, headers]
|
243
|
+
end
|
244
|
+
|
245
|
+
def self.encode_body(body, channel, frame_size)
|
246
|
+
# Spec is broken: Our errata says that it does define
|
247
|
+
# something, but it just doesn"t relate do method and
|
248
|
+
# properties frames. Which makes it, well, suboptimal.
|
249
|
+
# https://dev.rabbitmq.com/wiki/Amqp091Errata#section_11
|
250
|
+
limit = frame_size - 7 - 1
|
251
|
+
|
252
|
+
Array.new.tap do |array|
|
253
|
+
while body
|
254
|
+
payload, body = body[0, limit + 1], body[limit + 1, body.length - limit]
|
255
|
+
# array << [0x03, payload]
|
256
|
+
array << BodyFrame.new(payload, channel)
|
257
|
+
end
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
# We can return different:
|
262
|
+
# - instantiate given subclass of Method
|
263
|
+
# - create an OpenStruct object
|
264
|
+
# - create a hash
|
265
|
+
# - yield params into the block rather than just return
|
266
|
+
# @api plugin
|
267
|
+
def self.instantiate(*args, &block)
|
268
|
+
self.new(*args, &block)
|
269
|
+
# or OpenStruct.new(args.first)
|
270
|
+
# or args.first
|
271
|
+
# or block.call(*args)
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
275
|
+
class Connection < Protocol::Class
|
276
|
+
@name = "connection"
|
277
|
+
@method_id = 10
|
278
|
+
|
279
|
+
class Start < Protocol::Method
|
280
|
+
@name = "connection.start"
|
281
|
+
@method_id = 10
|
282
|
+
@index = 0x000A000A # 10, 10, 655370
|
283
|
+
@packed_indexes = [10, 10].pack(PACK_UINT16_X2).freeze
|
284
|
+
|
285
|
+
# @return
|
286
|
+
def self.decode(data)
|
287
|
+
offset = 0
|
288
|
+
version_major = data[offset, 1].unpack(PACK_CHAR).first
|
289
|
+
offset += 1
|
290
|
+
version_minor = data[offset, 1].unpack(PACK_CHAR).first
|
291
|
+
offset += 1
|
292
|
+
table_length = Table.length(data[offset, 4])
|
293
|
+
server_properties = Table.decode(data[offset, table_length + 4])
|
294
|
+
offset += table_length + 4
|
295
|
+
length = data[offset, 4].unpack(PACK_UINT32).first
|
296
|
+
offset += 4
|
297
|
+
mechanisms = data[offset, length]
|
298
|
+
offset += length
|
299
|
+
length = data[offset, 4].unpack(PACK_UINT32).first
|
300
|
+
offset += 4
|
301
|
+
locales = data[offset, length]
|
302
|
+
offset += length
|
303
|
+
self.new(version_major, version_minor, server_properties, mechanisms, locales)
|
304
|
+
end
|
305
|
+
|
306
|
+
attr_reader :version_major, :version_minor, :server_properties, :mechanisms, :locales
|
307
|
+
def initialize(version_major, version_minor, server_properties, mechanisms, locales)
|
308
|
+
@version_major = version_major
|
309
|
+
@version_minor = version_minor
|
310
|
+
@server_properties = server_properties
|
311
|
+
@mechanisms = mechanisms
|
312
|
+
@locales = locales
|
313
|
+
end
|
314
|
+
|
315
|
+
def self.has_content?
|
316
|
+
false
|
317
|
+
end
|
318
|
+
end
|
319
|
+
|
320
|
+
class StartOk < Protocol::Method
|
321
|
+
@name = "connection.start-ok"
|
322
|
+
@method_id = 11
|
323
|
+
@index = 0x000A000B # 10, 11, 655371
|
324
|
+
@packed_indexes = [10, 11].pack(PACK_UINT16_X2).freeze
|
325
|
+
|
326
|
+
def self.has_content?
|
327
|
+
false
|
328
|
+
end
|
329
|
+
|
330
|
+
# @return
|
331
|
+
# ["client_properties = nil", "mechanism = "PLAIN"", "response = nil", "locale = "en_US""]
|
332
|
+
def self.encode(client_properties, mechanism, response, locale)
|
333
|
+
channel = 0
|
334
|
+
buffer = ""
|
335
|
+
buffer << @packed_indexes
|
336
|
+
buffer << AMQ::Protocol::Table.encode(client_properties)
|
337
|
+
buffer << mechanism.bytesize.chr
|
338
|
+
buffer << mechanism
|
339
|
+
buffer << [response.bytesize].pack(PACK_UINT32)
|
340
|
+
buffer << response
|
341
|
+
buffer << locale.bytesize.chr
|
342
|
+
buffer << locale
|
343
|
+
MethodFrame.new(buffer, channel)
|
344
|
+
end
|
345
|
+
end
|
346
|
+
|
347
|
+
class Secure < Protocol::Method
|
348
|
+
@name = "connection.secure"
|
349
|
+
@method_id = 20
|
350
|
+
@index = 0x000A0014 # 10, 20, 655380
|
351
|
+
@packed_indexes = [10, 20].pack(PACK_UINT16_X2).freeze
|
352
|
+
|
353
|
+
# @return
|
354
|
+
def self.decode(data)
|
355
|
+
offset = 0
|
356
|
+
length = data[offset, 4].unpack(PACK_UINT32).first
|
357
|
+
offset += 4
|
358
|
+
challenge = data[offset, length]
|
359
|
+
offset += length
|
360
|
+
self.new(challenge)
|
361
|
+
end
|
362
|
+
|
363
|
+
attr_reader :challenge
|
364
|
+
def initialize(challenge)
|
365
|
+
@challenge = challenge
|
366
|
+
end
|
367
|
+
|
368
|
+
def self.has_content?
|
369
|
+
false
|
370
|
+
end
|
371
|
+
end
|
372
|
+
|
373
|
+
class SecureOk < Protocol::Method
|
374
|
+
@name = "connection.secure-ok"
|
375
|
+
@method_id = 21
|
376
|
+
@index = 0x000A0015 # 10, 21, 655381
|
377
|
+
@packed_indexes = [10, 21].pack(PACK_UINT16_X2).freeze
|
378
|
+
|
379
|
+
def self.has_content?
|
380
|
+
false
|
381
|
+
end
|
382
|
+
|
383
|
+
# @return
|
384
|
+
# ["response = nil"]
|
385
|
+
def self.encode(response)
|
386
|
+
channel = 0
|
387
|
+
buffer = ""
|
388
|
+
buffer << @packed_indexes
|
389
|
+
buffer << [response.bytesize].pack(PACK_UINT32)
|
390
|
+
buffer << response
|
391
|
+
MethodFrame.new(buffer, channel)
|
392
|
+
end
|
393
|
+
end
|
394
|
+
|
395
|
+
class Tune < Protocol::Method
|
396
|
+
@name = "connection.tune"
|
397
|
+
@method_id = 30
|
398
|
+
@index = 0x000A001E # 10, 30, 655390
|
399
|
+
@packed_indexes = [10, 30].pack(PACK_UINT16_X2).freeze
|
400
|
+
|
401
|
+
# @return
|
402
|
+
def self.decode(data)
|
403
|
+
offset = 0
|
404
|
+
channel_max = data[offset, 2].unpack(PACK_UINT16).first
|
405
|
+
offset += 2
|
406
|
+
frame_max = data[offset, 4].unpack(PACK_UINT32).first
|
407
|
+
offset += 4
|
408
|
+
heartbeat = data[offset, 2].unpack(PACK_UINT16).first
|
409
|
+
offset += 2
|
410
|
+
self.new(channel_max, frame_max, heartbeat)
|
411
|
+
end
|
412
|
+
|
413
|
+
attr_reader :channel_max, :frame_max, :heartbeat
|
414
|
+
def initialize(channel_max, frame_max, heartbeat)
|
415
|
+
@channel_max = channel_max
|
416
|
+
@frame_max = frame_max
|
417
|
+
@heartbeat = heartbeat
|
418
|
+
end
|
419
|
+
|
420
|
+
def self.has_content?
|
421
|
+
false
|
422
|
+
end
|
423
|
+
end
|
424
|
+
|
425
|
+
class TuneOk < Protocol::Method
|
426
|
+
@name = "connection.tune-ok"
|
427
|
+
@method_id = 31
|
428
|
+
@index = 0x000A001F # 10, 31, 655391
|
429
|
+
@packed_indexes = [10, 31].pack(PACK_UINT16_X2).freeze
|
430
|
+
|
431
|
+
def self.has_content?
|
432
|
+
false
|
433
|
+
end
|
434
|
+
|
435
|
+
# @return
|
436
|
+
# ["channel_max = false", "frame_max = false", "heartbeat = false"]
|
437
|
+
def self.encode(channel_max, frame_max, heartbeat)
|
438
|
+
channel = 0
|
439
|
+
buffer = ""
|
440
|
+
buffer << @packed_indexes
|
441
|
+
buffer << [channel_max].pack(PACK_UINT16)
|
442
|
+
buffer << [frame_max].pack(PACK_UINT32)
|
443
|
+
buffer << [heartbeat].pack(PACK_UINT16)
|
444
|
+
MethodFrame.new(buffer, channel)
|
445
|
+
end
|
446
|
+
end
|
447
|
+
|
448
|
+
class Open < Protocol::Method
|
449
|
+
@name = "connection.open"
|
450
|
+
@method_id = 40
|
451
|
+
@index = 0x000A0028 # 10, 40, 655400
|
452
|
+
@packed_indexes = [10, 40].pack(PACK_UINT16_X2).freeze
|
453
|
+
|
454
|
+
def self.has_content?
|
455
|
+
false
|
456
|
+
end
|
457
|
+
|
458
|
+
# @return
|
459
|
+
# ["virtual_host = "/"", "capabilities = EMPTY_STRING", "insist = false"]
|
460
|
+
def self.encode(virtual_host)
|
461
|
+
capabilities = EMPTY_STRING
|
462
|
+
insist = false
|
463
|
+
channel = 0
|
464
|
+
buffer = ""
|
465
|
+
buffer << @packed_indexes
|
466
|
+
buffer << virtual_host.bytesize.chr
|
467
|
+
buffer << virtual_host
|
468
|
+
buffer << capabilities.bytesize.chr
|
469
|
+
buffer << capabilities
|
470
|
+
bit_buffer = 0
|
471
|
+
bit_buffer = bit_buffer | (1 << 0) if insist
|
472
|
+
buffer << [bit_buffer].pack(PACK_CHAR)
|
473
|
+
MethodFrame.new(buffer, channel)
|
474
|
+
end
|
475
|
+
end
|
476
|
+
|
477
|
+
class OpenOk < Protocol::Method
|
478
|
+
@name = "connection.open-ok"
|
479
|
+
@method_id = 41
|
480
|
+
@index = 0x000A0029 # 10, 41, 655401
|
481
|
+
@packed_indexes = [10, 41].pack(PACK_UINT16_X2).freeze
|
482
|
+
|
483
|
+
# @return
|
484
|
+
def self.decode(data)
|
485
|
+
offset = 0
|
486
|
+
length = data[offset, 1].unpack(PACK_CHAR).first
|
487
|
+
offset += 1
|
488
|
+
known_hosts = data[offset, length]
|
489
|
+
offset += length
|
490
|
+
self.new(known_hosts)
|
491
|
+
end
|
492
|
+
|
493
|
+
attr_reader :known_hosts
|
494
|
+
def initialize(known_hosts)
|
495
|
+
@known_hosts = known_hosts
|
496
|
+
end
|
497
|
+
|
498
|
+
def self.has_content?
|
499
|
+
false
|
500
|
+
end
|
501
|
+
end
|
502
|
+
|
503
|
+
class Close < Protocol::Method
|
504
|
+
@name = "connection.close"
|
505
|
+
@method_id = 50
|
506
|
+
@index = 0x000A0032 # 10, 50, 655410
|
507
|
+
@packed_indexes = [10, 50].pack(PACK_UINT16_X2).freeze
|
508
|
+
|
509
|
+
# @return
|
510
|
+
def self.decode(data)
|
511
|
+
offset = 0
|
512
|
+
reply_code = data[offset, 2].unpack(PACK_UINT16).first
|
513
|
+
offset += 2
|
514
|
+
length = data[offset, 1].unpack(PACK_CHAR).first
|
515
|
+
offset += 1
|
516
|
+
reply_text = data[offset, length]
|
517
|
+
offset += length
|
518
|
+
class_id = data[offset, 2].unpack(PACK_UINT16).first
|
519
|
+
offset += 2
|
520
|
+
method_id = data[offset, 2].unpack(PACK_UINT16).first
|
521
|
+
offset += 2
|
522
|
+
if reply_code.eql?(200)
|
523
|
+
self.new(reply_code, reply_text, class_id, method_id)
|
524
|
+
else
|
525
|
+
raise Error[reply_code].new(reply_text)
|
526
|
+
end
|
527
|
+
end
|
528
|
+
|
529
|
+
attr_reader :reply_code, :reply_text, :class_id, :method_id
|
530
|
+
def initialize(reply_code, reply_text, class_id, method_id)
|
531
|
+
@reply_code = reply_code
|
532
|
+
@reply_text = reply_text
|
533
|
+
@class_id = class_id
|
534
|
+
@method_id = method_id
|
535
|
+
end
|
536
|
+
|
537
|
+
def self.has_content?
|
538
|
+
false
|
539
|
+
end
|
540
|
+
|
541
|
+
# @return
|
542
|
+
# ["reply_code = nil", "reply_text = EMPTY_STRING", "class_id = nil", "method_id = nil"]
|
543
|
+
def self.encode(reply_code, reply_text, class_id, method_id)
|
544
|
+
channel = 0
|
545
|
+
buffer = ""
|
546
|
+
buffer << @packed_indexes
|
547
|
+
buffer << [reply_code].pack(PACK_UINT16)
|
548
|
+
buffer << reply_text.bytesize.chr
|
549
|
+
buffer << reply_text
|
550
|
+
buffer << [class_id].pack(PACK_UINT16)
|
551
|
+
buffer << [method_id].pack(PACK_UINT16)
|
552
|
+
MethodFrame.new(buffer, channel)
|
553
|
+
end
|
554
|
+
end
|
555
|
+
|
556
|
+
class CloseOk < Protocol::Method
|
557
|
+
@name = "connection.close-ok"
|
558
|
+
@method_id = 51
|
559
|
+
@index = 0x000A0033 # 10, 51, 655411
|
560
|
+
@packed_indexes = [10, 51].pack(PACK_UINT16_X2).freeze
|
561
|
+
|
562
|
+
# @return
|
563
|
+
def self.decode(data)
|
564
|
+
offset = 0
|
565
|
+
self.new()
|
566
|
+
end
|
567
|
+
|
568
|
+
def initialize()
|
569
|
+
end
|
570
|
+
|
571
|
+
def self.has_content?
|
572
|
+
false
|
573
|
+
end
|
574
|
+
|
575
|
+
# @return
|
576
|
+
# []
|
577
|
+
def self.encode()
|
578
|
+
channel = 0
|
579
|
+
buffer = ""
|
580
|
+
buffer << @packed_indexes
|
581
|
+
MethodFrame.new(buffer, channel)
|
582
|
+
end
|
583
|
+
end
|
584
|
+
end
|
585
|
+
|
586
|
+
class Channel < Protocol::Class
|
587
|
+
@name = "channel"
|
588
|
+
@method_id = 20
|
589
|
+
|
590
|
+
class Open < Protocol::Method
|
591
|
+
@name = "channel.open"
|
592
|
+
@method_id = 10
|
593
|
+
@index = 0x0014000A # 20, 10, 1310730
|
594
|
+
@packed_indexes = [20, 10].pack(PACK_UINT16_X2).freeze
|
595
|
+
|
596
|
+
def self.has_content?
|
597
|
+
false
|
598
|
+
end
|
599
|
+
|
600
|
+
# @return
|
601
|
+
# ["out_of_band = EMPTY_STRING"]
|
602
|
+
def self.encode(channel, out_of_band)
|
603
|
+
buffer = ""
|
604
|
+
buffer << @packed_indexes
|
605
|
+
buffer << out_of_band.bytesize.chr
|
606
|
+
buffer << out_of_band
|
607
|
+
MethodFrame.new(buffer, channel)
|
608
|
+
end
|
609
|
+
end
|
610
|
+
|
611
|
+
class OpenOk < Protocol::Method
|
612
|
+
@name = "channel.open-ok"
|
613
|
+
@method_id = 11
|
614
|
+
@index = 0x0014000B # 20, 11, 1310731
|
615
|
+
@packed_indexes = [20, 11].pack(PACK_UINT16_X2).freeze
|
616
|
+
|
617
|
+
# @return
|
618
|
+
def self.decode(data)
|
619
|
+
offset = 0
|
620
|
+
length = data[offset, 4].unpack(PACK_UINT32).first
|
621
|
+
offset += 4
|
622
|
+
channel_id = data[offset, length]
|
623
|
+
offset += length
|
624
|
+
self.new(channel_id)
|
625
|
+
end
|
626
|
+
|
627
|
+
attr_reader :channel_id
|
628
|
+
def initialize(channel_id)
|
629
|
+
@channel_id = channel_id
|
630
|
+
end
|
631
|
+
|
632
|
+
def self.has_content?
|
633
|
+
false
|
634
|
+
end
|
635
|
+
end
|
636
|
+
|
637
|
+
class Flow < Protocol::Method
|
638
|
+
@name = "channel.flow"
|
639
|
+
@method_id = 20
|
640
|
+
@index = 0x00140014 # 20, 20, 1310740
|
641
|
+
@packed_indexes = [20, 20].pack(PACK_UINT16_X2).freeze
|
642
|
+
|
643
|
+
# @return
|
644
|
+
def self.decode(data)
|
645
|
+
offset = 0
|
646
|
+
bit_buffer = data[offset, 1].unpack(PACK_CHAR).first
|
647
|
+
offset += 1
|
648
|
+
active = (bit_buffer & (1 << 0)) != 0
|
649
|
+
self.new(active)
|
650
|
+
end
|
651
|
+
|
652
|
+
attr_reader :active
|
653
|
+
def initialize(active)
|
654
|
+
@active = active
|
655
|
+
end
|
656
|
+
|
657
|
+
def self.has_content?
|
658
|
+
false
|
659
|
+
end
|
660
|
+
|
661
|
+
# @return
|
662
|
+
# ["active = nil"]
|
663
|
+
def self.encode(channel, active)
|
664
|
+
buffer = ""
|
665
|
+
buffer << @packed_indexes
|
666
|
+
bit_buffer = 0
|
667
|
+
bit_buffer = bit_buffer | (1 << 0) if active
|
668
|
+
buffer << [bit_buffer].pack(PACK_CHAR)
|
669
|
+
MethodFrame.new(buffer, channel)
|
670
|
+
end
|
671
|
+
end
|
672
|
+
|
673
|
+
class FlowOk < Protocol::Method
|
674
|
+
@name = "channel.flow-ok"
|
675
|
+
@method_id = 21
|
676
|
+
@index = 0x00140015 # 20, 21, 1310741
|
677
|
+
@packed_indexes = [20, 21].pack(PACK_UINT16_X2).freeze
|
678
|
+
|
679
|
+
# @return
|
680
|
+
def self.decode(data)
|
681
|
+
offset = 0
|
682
|
+
bit_buffer = data[offset, 1].unpack(PACK_CHAR).first
|
683
|
+
offset += 1
|
684
|
+
active = (bit_buffer & (1 << 0)) != 0
|
685
|
+
self.new(active)
|
686
|
+
end
|
687
|
+
|
688
|
+
attr_reader :active
|
689
|
+
def initialize(active)
|
690
|
+
@active = active
|
691
|
+
end
|
692
|
+
|
693
|
+
def self.has_content?
|
694
|
+
false
|
695
|
+
end
|
696
|
+
|
697
|
+
# @return
|
698
|
+
# ["active = nil"]
|
699
|
+
def self.encode(channel, active)
|
700
|
+
buffer = ""
|
701
|
+
buffer << @packed_indexes
|
702
|
+
bit_buffer = 0
|
703
|
+
bit_buffer = bit_buffer | (1 << 0) if active
|
704
|
+
buffer << [bit_buffer].pack(PACK_CHAR)
|
705
|
+
MethodFrame.new(buffer, channel)
|
706
|
+
end
|
707
|
+
end
|
708
|
+
|
709
|
+
class Close < Protocol::Method
|
710
|
+
@name = "channel.close"
|
711
|
+
@method_id = 40
|
712
|
+
@index = 0x00140028 # 20, 40, 1310760
|
713
|
+
@packed_indexes = [20, 40].pack(PACK_UINT16_X2).freeze
|
714
|
+
|
715
|
+
# @return
|
716
|
+
def self.decode(data)
|
717
|
+
offset = 0
|
718
|
+
reply_code = data[offset, 2].unpack(PACK_UINT16).first
|
719
|
+
offset += 2
|
720
|
+
length = data[offset, 1].unpack(PACK_CHAR).first
|
721
|
+
offset += 1
|
722
|
+
reply_text = data[offset, length]
|
723
|
+
offset += length
|
724
|
+
class_id = data[offset, 2].unpack(PACK_UINT16).first
|
725
|
+
offset += 2
|
726
|
+
method_id = data[offset, 2].unpack(PACK_UINT16).first
|
727
|
+
offset += 2
|
728
|
+
if reply_code.eql?(200)
|
729
|
+
self.new(reply_code, reply_text, class_id, method_id)
|
730
|
+
else
|
731
|
+
raise Error[reply_code].new(reply_text)
|
732
|
+
end
|
733
|
+
end
|
734
|
+
|
735
|
+
attr_reader :reply_code, :reply_text, :class_id, :method_id
|
736
|
+
def initialize(reply_code, reply_text, class_id, method_id)
|
737
|
+
@reply_code = reply_code
|
738
|
+
@reply_text = reply_text
|
739
|
+
@class_id = class_id
|
740
|
+
@method_id = method_id
|
741
|
+
end
|
742
|
+
|
743
|
+
def self.has_content?
|
744
|
+
false
|
745
|
+
end
|
746
|
+
|
747
|
+
# @return
|
748
|
+
# ["reply_code = nil", "reply_text = EMPTY_STRING", "class_id = nil", "method_id = nil"]
|
749
|
+
def self.encode(channel, reply_code, reply_text, class_id, method_id)
|
750
|
+
buffer = ""
|
751
|
+
buffer << @packed_indexes
|
752
|
+
buffer << [reply_code].pack(PACK_UINT16)
|
753
|
+
buffer << reply_text.bytesize.chr
|
754
|
+
buffer << reply_text
|
755
|
+
buffer << [class_id].pack(PACK_UINT16)
|
756
|
+
buffer << [method_id].pack(PACK_UINT16)
|
757
|
+
MethodFrame.new(buffer, channel)
|
758
|
+
end
|
759
|
+
end
|
760
|
+
|
761
|
+
class CloseOk < Protocol::Method
|
762
|
+
@name = "channel.close-ok"
|
763
|
+
@method_id = 41
|
764
|
+
@index = 0x00140029 # 20, 41, 1310761
|
765
|
+
@packed_indexes = [20, 41].pack(PACK_UINT16_X2).freeze
|
766
|
+
|
767
|
+
# @return
|
768
|
+
def self.decode(data)
|
769
|
+
offset = 0
|
770
|
+
self.new()
|
771
|
+
end
|
772
|
+
|
773
|
+
def initialize()
|
774
|
+
end
|
775
|
+
|
776
|
+
def self.has_content?
|
777
|
+
false
|
778
|
+
end
|
779
|
+
|
780
|
+
# @return
|
781
|
+
# []
|
782
|
+
def self.encode(channel)
|
783
|
+
buffer = ""
|
784
|
+
buffer << @packed_indexes
|
785
|
+
MethodFrame.new(buffer, channel)
|
786
|
+
end
|
787
|
+
end
|
788
|
+
end
|
789
|
+
|
790
|
+
class Exchange < Protocol::Class
|
791
|
+
@name = "exchange"
|
792
|
+
@method_id = 40
|
793
|
+
|
794
|
+
class Declare < Protocol::Method
|
795
|
+
@name = "exchange.declare"
|
796
|
+
@method_id = 10
|
797
|
+
@index = 0x0028000A # 40, 10, 2621450
|
798
|
+
@packed_indexes = [40, 10].pack(PACK_UINT16_X2).freeze
|
799
|
+
|
800
|
+
def self.has_content?
|
801
|
+
false
|
802
|
+
end
|
803
|
+
|
804
|
+
# @return
|
805
|
+
# ["ticket = 0", "exchange = nil", "type = "direct"", "passive = false", "durable = false", "auto_delete = false", "internal = false", "nowait = false", "arguments = {}"]
|
806
|
+
def self.encode(channel, exchange, type, passive, durable, auto_delete, internal, nowait, arguments)
|
807
|
+
ticket = 0
|
808
|
+
buffer = ""
|
809
|
+
buffer << @packed_indexes
|
810
|
+
buffer << [ticket].pack(PACK_UINT16)
|
811
|
+
buffer << exchange.bytesize.chr
|
812
|
+
buffer << exchange
|
813
|
+
buffer << type.bytesize.chr
|
814
|
+
buffer << type
|
815
|
+
bit_buffer = 0
|
816
|
+
bit_buffer = bit_buffer | (1 << 0) if passive
|
817
|
+
bit_buffer = bit_buffer | (1 << 1) if durable
|
818
|
+
bit_buffer = bit_buffer | (1 << 2) if auto_delete
|
819
|
+
bit_buffer = bit_buffer | (1 << 3) if internal
|
820
|
+
bit_buffer = bit_buffer | (1 << 4) if nowait
|
821
|
+
buffer << [bit_buffer].pack(PACK_CHAR)
|
822
|
+
buffer << AMQ::Protocol::Table.encode(arguments)
|
823
|
+
MethodFrame.new(buffer, channel)
|
824
|
+
end
|
825
|
+
end
|
826
|
+
|
827
|
+
class DeclareOk < Protocol::Method
|
828
|
+
@name = "exchange.declare-ok"
|
829
|
+
@method_id = 11
|
830
|
+
@index = 0x0028000B # 40, 11, 2621451
|
831
|
+
@packed_indexes = [40, 11].pack(PACK_UINT16_X2).freeze
|
832
|
+
|
833
|
+
# @return
|
834
|
+
def self.decode(data)
|
835
|
+
offset = 0
|
836
|
+
self.new()
|
837
|
+
end
|
838
|
+
|
839
|
+
def initialize()
|
840
|
+
end
|
841
|
+
|
842
|
+
def self.has_content?
|
843
|
+
false
|
844
|
+
end
|
845
|
+
end
|
846
|
+
|
847
|
+
class Delete < Protocol::Method
|
848
|
+
@name = "exchange.delete"
|
849
|
+
@method_id = 20
|
850
|
+
@index = 0x00280014 # 40, 20, 2621460
|
851
|
+
@packed_indexes = [40, 20].pack(PACK_UINT16_X2).freeze
|
852
|
+
|
853
|
+
def self.has_content?
|
854
|
+
false
|
855
|
+
end
|
856
|
+
|
857
|
+
# @return
|
858
|
+
# ["ticket = 0", "exchange = nil", "if_unused = false", "nowait = false"]
|
859
|
+
def self.encode(channel, exchange, if_unused, nowait)
|
860
|
+
ticket = 0
|
861
|
+
buffer = ""
|
862
|
+
buffer << @packed_indexes
|
863
|
+
buffer << [ticket].pack(PACK_UINT16)
|
864
|
+
buffer << exchange.bytesize.chr
|
865
|
+
buffer << exchange
|
866
|
+
bit_buffer = 0
|
867
|
+
bit_buffer = bit_buffer | (1 << 0) if if_unused
|
868
|
+
bit_buffer = bit_buffer | (1 << 1) if nowait
|
869
|
+
buffer << [bit_buffer].pack(PACK_CHAR)
|
870
|
+
MethodFrame.new(buffer, channel)
|
871
|
+
end
|
872
|
+
end
|
873
|
+
|
874
|
+
class DeleteOk < Protocol::Method
|
875
|
+
@name = "exchange.delete-ok"
|
876
|
+
@method_id = 21
|
877
|
+
@index = 0x00280015 # 40, 21, 2621461
|
878
|
+
@packed_indexes = [40, 21].pack(PACK_UINT16_X2).freeze
|
879
|
+
|
880
|
+
# @return
|
881
|
+
def self.decode(data)
|
882
|
+
offset = 0
|
883
|
+
self.new()
|
884
|
+
end
|
885
|
+
|
886
|
+
def initialize()
|
887
|
+
end
|
888
|
+
|
889
|
+
def self.has_content?
|
890
|
+
false
|
891
|
+
end
|
892
|
+
end
|
893
|
+
|
894
|
+
class Bind < Protocol::Method
|
895
|
+
@name = "exchange.bind"
|
896
|
+
@method_id = 30
|
897
|
+
@index = 0x0028001E # 40, 30, 2621470
|
898
|
+
@packed_indexes = [40, 30].pack(PACK_UINT16_X2).freeze
|
899
|
+
|
900
|
+
def self.has_content?
|
901
|
+
false
|
902
|
+
end
|
903
|
+
|
904
|
+
# @return
|
905
|
+
# ["ticket = 0", "destination = nil", "source = nil", "routing_key = EMPTY_STRING", "nowait = false", "arguments = {}"]
|
906
|
+
def self.encode(channel, destination, source, routing_key, nowait, arguments)
|
907
|
+
ticket = 0
|
908
|
+
buffer = ""
|
909
|
+
buffer << @packed_indexes
|
910
|
+
buffer << [ticket].pack(PACK_UINT16)
|
911
|
+
buffer << destination.bytesize.chr
|
912
|
+
buffer << destination
|
913
|
+
buffer << source.bytesize.chr
|
914
|
+
buffer << source
|
915
|
+
buffer << routing_key.bytesize.chr
|
916
|
+
buffer << routing_key
|
917
|
+
bit_buffer = 0
|
918
|
+
bit_buffer = bit_buffer | (1 << 0) if nowait
|
919
|
+
buffer << [bit_buffer].pack(PACK_CHAR)
|
920
|
+
buffer << AMQ::Protocol::Table.encode(arguments)
|
921
|
+
MethodFrame.new(buffer, channel)
|
922
|
+
end
|
923
|
+
end
|
924
|
+
|
925
|
+
class BindOk < Protocol::Method
|
926
|
+
@name = "exchange.bind-ok"
|
927
|
+
@method_id = 31
|
928
|
+
@index = 0x0028001F # 40, 31, 2621471
|
929
|
+
@packed_indexes = [40, 31].pack(PACK_UINT16_X2).freeze
|
930
|
+
|
931
|
+
# @return
|
932
|
+
def self.decode(data)
|
933
|
+
offset = 0
|
934
|
+
self.new()
|
935
|
+
end
|
936
|
+
|
937
|
+
def initialize()
|
938
|
+
end
|
939
|
+
|
940
|
+
def self.has_content?
|
941
|
+
false
|
942
|
+
end
|
943
|
+
end
|
944
|
+
|
945
|
+
class Unbind < Protocol::Method
|
946
|
+
@name = "exchange.unbind"
|
947
|
+
@method_id = 40
|
948
|
+
@index = 0x00280028 # 40, 40, 2621480
|
949
|
+
@packed_indexes = [40, 40].pack(PACK_UINT16_X2).freeze
|
950
|
+
|
951
|
+
def self.has_content?
|
952
|
+
false
|
953
|
+
end
|
954
|
+
|
955
|
+
# @return
|
956
|
+
# ["ticket = 0", "destination = nil", "source = nil", "routing_key = EMPTY_STRING", "nowait = false", "arguments = {}"]
|
957
|
+
def self.encode(channel, destination, source, routing_key, nowait, arguments)
|
958
|
+
ticket = 0
|
959
|
+
buffer = ""
|
960
|
+
buffer << @packed_indexes
|
961
|
+
buffer << [ticket].pack(PACK_UINT16)
|
962
|
+
buffer << destination.bytesize.chr
|
963
|
+
buffer << destination
|
964
|
+
buffer << source.bytesize.chr
|
965
|
+
buffer << source
|
966
|
+
buffer << routing_key.bytesize.chr
|
967
|
+
buffer << routing_key
|
968
|
+
bit_buffer = 0
|
969
|
+
bit_buffer = bit_buffer | (1 << 0) if nowait
|
970
|
+
buffer << [bit_buffer].pack(PACK_CHAR)
|
971
|
+
buffer << AMQ::Protocol::Table.encode(arguments)
|
972
|
+
MethodFrame.new(buffer, channel)
|
973
|
+
end
|
974
|
+
end
|
975
|
+
|
976
|
+
class UnbindOk < Protocol::Method
|
977
|
+
@name = "exchange.unbind-ok"
|
978
|
+
@method_id = 51
|
979
|
+
@index = 0x00280033 # 40, 51, 2621491
|
980
|
+
@packed_indexes = [40, 51].pack(PACK_UINT16_X2).freeze
|
981
|
+
|
982
|
+
# @return
|
983
|
+
def self.decode(data)
|
984
|
+
offset = 0
|
985
|
+
self.new()
|
986
|
+
end
|
987
|
+
|
988
|
+
def initialize()
|
989
|
+
end
|
990
|
+
|
991
|
+
def self.has_content?
|
992
|
+
false
|
993
|
+
end
|
994
|
+
end
|
995
|
+
end
|
996
|
+
|
997
|
+
class Queue < Protocol::Class
|
998
|
+
@name = "queue"
|
999
|
+
@method_id = 50
|
1000
|
+
|
1001
|
+
class Declare < Protocol::Method
|
1002
|
+
@name = "queue.declare"
|
1003
|
+
@method_id = 10
|
1004
|
+
@index = 0x0032000A # 50, 10, 3276810
|
1005
|
+
@packed_indexes = [50, 10].pack(PACK_UINT16_X2).freeze
|
1006
|
+
|
1007
|
+
def self.has_content?
|
1008
|
+
false
|
1009
|
+
end
|
1010
|
+
|
1011
|
+
# @return
|
1012
|
+
# ["ticket = 0", "queue = EMPTY_STRING", "passive = false", "durable = false", "exclusive = false", "auto_delete = false", "nowait = false", "arguments = {}"]
|
1013
|
+
def self.encode(channel, queue, passive, durable, exclusive, auto_delete, nowait, arguments)
|
1014
|
+
ticket = 0
|
1015
|
+
buffer = ""
|
1016
|
+
buffer << @packed_indexes
|
1017
|
+
buffer << [ticket].pack(PACK_UINT16)
|
1018
|
+
buffer << queue.bytesize.chr
|
1019
|
+
buffer << queue
|
1020
|
+
bit_buffer = 0
|
1021
|
+
bit_buffer = bit_buffer | (1 << 0) if passive
|
1022
|
+
bit_buffer = bit_buffer | (1 << 1) if durable
|
1023
|
+
bit_buffer = bit_buffer | (1 << 2) if exclusive
|
1024
|
+
bit_buffer = bit_buffer | (1 << 3) if auto_delete
|
1025
|
+
bit_buffer = bit_buffer | (1 << 4) if nowait
|
1026
|
+
buffer << [bit_buffer].pack(PACK_CHAR)
|
1027
|
+
buffer << AMQ::Protocol::Table.encode(arguments)
|
1028
|
+
MethodFrame.new(buffer, channel)
|
1029
|
+
end
|
1030
|
+
end
|
1031
|
+
|
1032
|
+
class DeclareOk < Protocol::Method
|
1033
|
+
@name = "queue.declare-ok"
|
1034
|
+
@method_id = 11
|
1035
|
+
@index = 0x0032000B # 50, 11, 3276811
|
1036
|
+
@packed_indexes = [50, 11].pack(PACK_UINT16_X2).freeze
|
1037
|
+
|
1038
|
+
# @return
|
1039
|
+
def self.decode(data)
|
1040
|
+
offset = 0
|
1041
|
+
length = data[offset, 1].unpack(PACK_CHAR).first
|
1042
|
+
offset += 1
|
1043
|
+
queue = data[offset, length]
|
1044
|
+
offset += length
|
1045
|
+
message_count = data[offset, 4].unpack(PACK_UINT32).first
|
1046
|
+
offset += 4
|
1047
|
+
consumer_count = data[offset, 4].unpack(PACK_UINT32).first
|
1048
|
+
offset += 4
|
1049
|
+
self.new(queue, message_count, consumer_count)
|
1050
|
+
end
|
1051
|
+
|
1052
|
+
attr_reader :queue, :message_count, :consumer_count
|
1053
|
+
def initialize(queue, message_count, consumer_count)
|
1054
|
+
@queue = queue
|
1055
|
+
@message_count = message_count
|
1056
|
+
@consumer_count = consumer_count
|
1057
|
+
end
|
1058
|
+
|
1059
|
+
def self.has_content?
|
1060
|
+
false
|
1061
|
+
end
|
1062
|
+
end
|
1063
|
+
|
1064
|
+
class Bind < Protocol::Method
|
1065
|
+
@name = "queue.bind"
|
1066
|
+
@method_id = 20
|
1067
|
+
@index = 0x00320014 # 50, 20, 3276820
|
1068
|
+
@packed_indexes = [50, 20].pack(PACK_UINT16_X2).freeze
|
1069
|
+
|
1070
|
+
def self.has_content?
|
1071
|
+
false
|
1072
|
+
end
|
1073
|
+
|
1074
|
+
# @return
|
1075
|
+
# ["ticket = 0", "queue = EMPTY_STRING", "exchange = nil", "routing_key = EMPTY_STRING", "nowait = false", "arguments = {}"]
|
1076
|
+
def self.encode(channel, queue, exchange, routing_key, nowait, arguments)
|
1077
|
+
ticket = 0
|
1078
|
+
buffer = ""
|
1079
|
+
buffer << @packed_indexes
|
1080
|
+
buffer << [ticket].pack(PACK_UINT16)
|
1081
|
+
buffer << queue.bytesize.chr
|
1082
|
+
buffer << queue
|
1083
|
+
buffer << exchange.bytesize.chr
|
1084
|
+
buffer << exchange
|
1085
|
+
buffer << routing_key.bytesize.chr
|
1086
|
+
buffer << routing_key
|
1087
|
+
bit_buffer = 0
|
1088
|
+
bit_buffer = bit_buffer | (1 << 0) if nowait
|
1089
|
+
buffer << [bit_buffer].pack(PACK_CHAR)
|
1090
|
+
buffer << AMQ::Protocol::Table.encode(arguments)
|
1091
|
+
MethodFrame.new(buffer, channel)
|
1092
|
+
end
|
1093
|
+
end
|
1094
|
+
|
1095
|
+
class BindOk < Protocol::Method
|
1096
|
+
@name = "queue.bind-ok"
|
1097
|
+
@method_id = 21
|
1098
|
+
@index = 0x00320015 # 50, 21, 3276821
|
1099
|
+
@packed_indexes = [50, 21].pack(PACK_UINT16_X2).freeze
|
1100
|
+
|
1101
|
+
# @return
|
1102
|
+
def self.decode(data)
|
1103
|
+
offset = 0
|
1104
|
+
self.new()
|
1105
|
+
end
|
1106
|
+
|
1107
|
+
def initialize()
|
1108
|
+
end
|
1109
|
+
|
1110
|
+
def self.has_content?
|
1111
|
+
false
|
1112
|
+
end
|
1113
|
+
end
|
1114
|
+
|
1115
|
+
class Purge < Protocol::Method
|
1116
|
+
@name = "queue.purge"
|
1117
|
+
@method_id = 30
|
1118
|
+
@index = 0x0032001E # 50, 30, 3276830
|
1119
|
+
@packed_indexes = [50, 30].pack(PACK_UINT16_X2).freeze
|
1120
|
+
|
1121
|
+
def self.has_content?
|
1122
|
+
false
|
1123
|
+
end
|
1124
|
+
|
1125
|
+
# @return
|
1126
|
+
# ["ticket = 0", "queue = EMPTY_STRING", "nowait = false"]
|
1127
|
+
def self.encode(channel, queue, nowait)
|
1128
|
+
ticket = 0
|
1129
|
+
buffer = ""
|
1130
|
+
buffer << @packed_indexes
|
1131
|
+
buffer << [ticket].pack(PACK_UINT16)
|
1132
|
+
buffer << queue.bytesize.chr
|
1133
|
+
buffer << queue
|
1134
|
+
bit_buffer = 0
|
1135
|
+
bit_buffer = bit_buffer | (1 << 0) if nowait
|
1136
|
+
buffer << [bit_buffer].pack(PACK_CHAR)
|
1137
|
+
MethodFrame.new(buffer, channel)
|
1138
|
+
end
|
1139
|
+
end
|
1140
|
+
|
1141
|
+
class PurgeOk < Protocol::Method
|
1142
|
+
@name = "queue.purge-ok"
|
1143
|
+
@method_id = 31
|
1144
|
+
@index = 0x0032001F # 50, 31, 3276831
|
1145
|
+
@packed_indexes = [50, 31].pack(PACK_UINT16_X2).freeze
|
1146
|
+
|
1147
|
+
# @return
|
1148
|
+
def self.decode(data)
|
1149
|
+
offset = 0
|
1150
|
+
message_count = data[offset, 4].unpack(PACK_UINT32).first
|
1151
|
+
offset += 4
|
1152
|
+
self.new(message_count)
|
1153
|
+
end
|
1154
|
+
|
1155
|
+
attr_reader :message_count
|
1156
|
+
def initialize(message_count)
|
1157
|
+
@message_count = message_count
|
1158
|
+
end
|
1159
|
+
|
1160
|
+
def self.has_content?
|
1161
|
+
false
|
1162
|
+
end
|
1163
|
+
end
|
1164
|
+
|
1165
|
+
class Delete < Protocol::Method
|
1166
|
+
@name = "queue.delete"
|
1167
|
+
@method_id = 40
|
1168
|
+
@index = 0x00320028 # 50, 40, 3276840
|
1169
|
+
@packed_indexes = [50, 40].pack(PACK_UINT16_X2).freeze
|
1170
|
+
|
1171
|
+
def self.has_content?
|
1172
|
+
false
|
1173
|
+
end
|
1174
|
+
|
1175
|
+
# @return
|
1176
|
+
# ["ticket = 0", "queue = EMPTY_STRING", "if_unused = false", "if_empty = false", "nowait = false"]
|
1177
|
+
def self.encode(channel, queue, if_unused, if_empty, nowait)
|
1178
|
+
ticket = 0
|
1179
|
+
buffer = ""
|
1180
|
+
buffer << @packed_indexes
|
1181
|
+
buffer << [ticket].pack(PACK_UINT16)
|
1182
|
+
buffer << queue.bytesize.chr
|
1183
|
+
buffer << queue
|
1184
|
+
bit_buffer = 0
|
1185
|
+
bit_buffer = bit_buffer | (1 << 0) if if_unused
|
1186
|
+
bit_buffer = bit_buffer | (1 << 1) if if_empty
|
1187
|
+
bit_buffer = bit_buffer | (1 << 2) if nowait
|
1188
|
+
buffer << [bit_buffer].pack(PACK_CHAR)
|
1189
|
+
MethodFrame.new(buffer, channel)
|
1190
|
+
end
|
1191
|
+
end
|
1192
|
+
|
1193
|
+
class DeleteOk < Protocol::Method
|
1194
|
+
@name = "queue.delete-ok"
|
1195
|
+
@method_id = 41
|
1196
|
+
@index = 0x00320029 # 50, 41, 3276841
|
1197
|
+
@packed_indexes = [50, 41].pack(PACK_UINT16_X2).freeze
|
1198
|
+
|
1199
|
+
# @return
|
1200
|
+
def self.decode(data)
|
1201
|
+
offset = 0
|
1202
|
+
message_count = data[offset, 4].unpack(PACK_UINT32).first
|
1203
|
+
offset += 4
|
1204
|
+
self.new(message_count)
|
1205
|
+
end
|
1206
|
+
|
1207
|
+
attr_reader :message_count
|
1208
|
+
def initialize(message_count)
|
1209
|
+
@message_count = message_count
|
1210
|
+
end
|
1211
|
+
|
1212
|
+
def self.has_content?
|
1213
|
+
false
|
1214
|
+
end
|
1215
|
+
end
|
1216
|
+
|
1217
|
+
class Unbind < Protocol::Method
|
1218
|
+
@name = "queue.unbind"
|
1219
|
+
@method_id = 50
|
1220
|
+
@index = 0x00320032 # 50, 50, 3276850
|
1221
|
+
@packed_indexes = [50, 50].pack(PACK_UINT16_X2).freeze
|
1222
|
+
|
1223
|
+
def self.has_content?
|
1224
|
+
false
|
1225
|
+
end
|
1226
|
+
|
1227
|
+
# @return
|
1228
|
+
# ["ticket = 0", "queue = EMPTY_STRING", "exchange = nil", "routing_key = EMPTY_STRING", "arguments = {}"]
|
1229
|
+
def self.encode(channel, queue, exchange, routing_key, arguments)
|
1230
|
+
ticket = 0
|
1231
|
+
buffer = ""
|
1232
|
+
buffer << @packed_indexes
|
1233
|
+
buffer << [ticket].pack(PACK_UINT16)
|
1234
|
+
buffer << queue.bytesize.chr
|
1235
|
+
buffer << queue
|
1236
|
+
buffer << exchange.bytesize.chr
|
1237
|
+
buffer << exchange
|
1238
|
+
buffer << routing_key.bytesize.chr
|
1239
|
+
buffer << routing_key
|
1240
|
+
buffer << AMQ::Protocol::Table.encode(arguments)
|
1241
|
+
MethodFrame.new(buffer, channel)
|
1242
|
+
end
|
1243
|
+
end
|
1244
|
+
|
1245
|
+
class UnbindOk < Protocol::Method
|
1246
|
+
@name = "queue.unbind-ok"
|
1247
|
+
@method_id = 51
|
1248
|
+
@index = 0x00320033 # 50, 51, 3276851
|
1249
|
+
@packed_indexes = [50, 51].pack(PACK_UINT16_X2).freeze
|
1250
|
+
|
1251
|
+
# @return
|
1252
|
+
def self.decode(data)
|
1253
|
+
offset = 0
|
1254
|
+
self.new()
|
1255
|
+
end
|
1256
|
+
|
1257
|
+
def initialize()
|
1258
|
+
end
|
1259
|
+
|
1260
|
+
def self.has_content?
|
1261
|
+
false
|
1262
|
+
end
|
1263
|
+
end
|
1264
|
+
end
|
1265
|
+
|
1266
|
+
class Basic < Protocol::Class
|
1267
|
+
@name = "basic"
|
1268
|
+
@method_id = 60
|
1269
|
+
|
1270
|
+
PROPERTIES = [
|
1271
|
+
:content_type, # shortstr
|
1272
|
+
:content_encoding, # shortstr
|
1273
|
+
:headers, # table
|
1274
|
+
:delivery_mode, # octet
|
1275
|
+
:priority, # octet
|
1276
|
+
:correlation_id, # shortstr
|
1277
|
+
:reply_to, # shortstr
|
1278
|
+
:expiration, # shortstr
|
1279
|
+
:message_id, # shortstr
|
1280
|
+
:timestamp, # timestamp
|
1281
|
+
:type, # shortstr
|
1282
|
+
:user_id, # shortstr
|
1283
|
+
:app_id, # shortstr
|
1284
|
+
:cluster_id, # shortstr
|
1285
|
+
]
|
1286
|
+
|
1287
|
+
# 1 << 15
|
1288
|
+
def self.encode_content_type(value)
|
1289
|
+
buffer = ""
|
1290
|
+
buffer << value.bytesize.chr
|
1291
|
+
buffer << value
|
1292
|
+
[0, 0x8000, buffer]
|
1293
|
+
end
|
1294
|
+
|
1295
|
+
# 1 << 14
|
1296
|
+
def self.encode_content_encoding(value)
|
1297
|
+
buffer = ""
|
1298
|
+
buffer << value.bytesize.chr
|
1299
|
+
buffer << value
|
1300
|
+
[1, 0x4000, buffer]
|
1301
|
+
end
|
1302
|
+
|
1303
|
+
# 1 << 13
|
1304
|
+
def self.encode_headers(value)
|
1305
|
+
buffer = ""
|
1306
|
+
buffer << AMQ::Protocol::Table.encode(value)
|
1307
|
+
[2, 0x2000, buffer]
|
1308
|
+
end
|
1309
|
+
|
1310
|
+
# 1 << 12
|
1311
|
+
def self.encode_delivery_mode(value)
|
1312
|
+
buffer = ""
|
1313
|
+
buffer << [value].pack(PACK_CHAR)
|
1314
|
+
[3, 0x1000, buffer]
|
1315
|
+
end
|
1316
|
+
|
1317
|
+
# 1 << 11
|
1318
|
+
def self.encode_priority(value)
|
1319
|
+
buffer = ""
|
1320
|
+
buffer << [value].pack(PACK_CHAR)
|
1321
|
+
[4, 0x0800, buffer]
|
1322
|
+
end
|
1323
|
+
|
1324
|
+
# 1 << 10
|
1325
|
+
def self.encode_correlation_id(value)
|
1326
|
+
buffer = ""
|
1327
|
+
buffer << value.bytesize.chr
|
1328
|
+
buffer << value
|
1329
|
+
[5, 0x0400, buffer]
|
1330
|
+
end
|
1331
|
+
|
1332
|
+
# 1 << 9
|
1333
|
+
def self.encode_reply_to(value)
|
1334
|
+
buffer = ""
|
1335
|
+
buffer << value.bytesize.chr
|
1336
|
+
buffer << value
|
1337
|
+
[6, 0x0200, buffer]
|
1338
|
+
end
|
1339
|
+
|
1340
|
+
# 1 << 8
|
1341
|
+
def self.encode_expiration(value)
|
1342
|
+
buffer = ""
|
1343
|
+
buffer << value.bytesize.chr
|
1344
|
+
buffer << value
|
1345
|
+
[7, 0x0100, buffer]
|
1346
|
+
end
|
1347
|
+
|
1348
|
+
# 1 << 7
|
1349
|
+
def self.encode_message_id(value)
|
1350
|
+
buffer = ""
|
1351
|
+
buffer << value.bytesize.chr
|
1352
|
+
buffer << value
|
1353
|
+
[8, 0x0080, buffer]
|
1354
|
+
end
|
1355
|
+
|
1356
|
+
# 1 << 6
|
1357
|
+
def self.encode_timestamp(value)
|
1358
|
+
buffer = ""
|
1359
|
+
buffer << AMQ::Hacks.pack_64_big_endian(value)
|
1360
|
+
[9, 0x0040, buffer]
|
1361
|
+
end
|
1362
|
+
|
1363
|
+
# 1 << 5
|
1364
|
+
def self.encode_type(value)
|
1365
|
+
buffer = ""
|
1366
|
+
buffer << value.bytesize.chr
|
1367
|
+
buffer << value
|
1368
|
+
[10, 0x0020, buffer]
|
1369
|
+
end
|
1370
|
+
|
1371
|
+
# 1 << 4
|
1372
|
+
def self.encode_user_id(value)
|
1373
|
+
buffer = ""
|
1374
|
+
buffer << value.bytesize.chr
|
1375
|
+
buffer << value
|
1376
|
+
[11, 0x0010, buffer]
|
1377
|
+
end
|
1378
|
+
|
1379
|
+
# 1 << 3
|
1380
|
+
def self.encode_app_id(value)
|
1381
|
+
buffer = ""
|
1382
|
+
buffer << value.bytesize.chr
|
1383
|
+
buffer << value
|
1384
|
+
[12, 0x0008, buffer]
|
1385
|
+
end
|
1386
|
+
|
1387
|
+
# 1 << 2
|
1388
|
+
def self.encode_cluster_id(value)
|
1389
|
+
buffer = ""
|
1390
|
+
buffer << value.bytesize.chr
|
1391
|
+
buffer << value
|
1392
|
+
[13, 0x0004, buffer]
|
1393
|
+
end
|
1394
|
+
|
1395
|
+
def self.encode_properties(body_size, properties)
|
1396
|
+
pieces, flags = [], 0
|
1397
|
+
|
1398
|
+
properties.each do |key, value|
|
1399
|
+
i, f, result = self.send(:"encode_#{key}", value)
|
1400
|
+
flags |= f
|
1401
|
+
pieces[i] = result
|
1402
|
+
end
|
1403
|
+
|
1404
|
+
# result = [60, 0, body_size, flags].pack("n2Qn")
|
1405
|
+
result = [60, 0].pack(PACK_UINT16_X2)
|
1406
|
+
result += AMQ::Hacks.pack_64_big_endian(body_size)
|
1407
|
+
result += [flags].pack(PACK_UINT16)
|
1408
|
+
result + pieces.join(EMPTY_STRING)
|
1409
|
+
end
|
1410
|
+
|
1411
|
+
# THIS DECODES ONLY FLAGS
|
1412
|
+
DECODE_PROPERTIES = {
|
1413
|
+
0x8000 => :content_type,
|
1414
|
+
0x4000 => :content_encoding,
|
1415
|
+
0x2000 => :headers,
|
1416
|
+
0x1000 => :delivery_mode,
|
1417
|
+
0x0800 => :priority,
|
1418
|
+
0x0400 => :correlation_id,
|
1419
|
+
0x0200 => :reply_to,
|
1420
|
+
0x0100 => :expiration,
|
1421
|
+
0x0080 => :message_id,
|
1422
|
+
0x0040 => :timestamp,
|
1423
|
+
0x0020 => :type,
|
1424
|
+
0x0010 => :user_id,
|
1425
|
+
0x0008 => :app_id,
|
1426
|
+
0x0004 => :cluster_id,
|
1427
|
+
}
|
1428
|
+
|
1429
|
+
DECODE_PROPERTIES_TYPE = {
|
1430
|
+
0x8000 => :shortstr,
|
1431
|
+
0x4000 => :shortstr,
|
1432
|
+
0x2000 => :table,
|
1433
|
+
0x1000 => :octet,
|
1434
|
+
0x0800 => :octet,
|
1435
|
+
0x0400 => :shortstr,
|
1436
|
+
0x0200 => :shortstr,
|
1437
|
+
0x0100 => :shortstr,
|
1438
|
+
0x0080 => :shortstr,
|
1439
|
+
0x0040 => :timestamp,
|
1440
|
+
0x0020 => :shortstr,
|
1441
|
+
0x0010 => :shortstr,
|
1442
|
+
0x0008 => :shortstr,
|
1443
|
+
0x0004 => :shortstr,
|
1444
|
+
}
|
1445
|
+
|
1446
|
+
# Hash doesn"t give any guarantees on keys order, we will do it in a
|
1447
|
+
# straightforward way
|
1448
|
+
DECODE_PROPERTIES_KEYS = [
|
1449
|
+
0x8000,
|
1450
|
+
0x4000,
|
1451
|
+
0x2000,
|
1452
|
+
0x1000,
|
1453
|
+
0x0800,
|
1454
|
+
0x0400,
|
1455
|
+
0x0200,
|
1456
|
+
0x0100,
|
1457
|
+
0x0080,
|
1458
|
+
0x0040,
|
1459
|
+
0x0020,
|
1460
|
+
0x0010,
|
1461
|
+
0x0008,
|
1462
|
+
0x0004,
|
1463
|
+
]
|
1464
|
+
|
1465
|
+
def self.decode_properties(data)
|
1466
|
+
offset, data_length, properties = 0, data.bytesize, {}
|
1467
|
+
|
1468
|
+
compressed_index = data[offset, 2].unpack(PACK_UINT16)[0]
|
1469
|
+
offset += 2
|
1470
|
+
while data_length > offset
|
1471
|
+
DECODE_PROPERTIES_KEYS.each do |key|
|
1472
|
+
next unless compressed_index >= key
|
1473
|
+
compressed_index -= key
|
1474
|
+
name = DECODE_PROPERTIES[key] || raise(RuntimeError.new("No property found for index #{index.inspect}!"))
|
1475
|
+
case DECODE_PROPERTIES_TYPE[key]
|
1476
|
+
when :shortstr
|
1477
|
+
size = data[offset, 1].unpack(PACK_CHAR)[0]
|
1478
|
+
offset += 1
|
1479
|
+
result = data[offset, size]
|
1480
|
+
when :octet
|
1481
|
+
size = 1
|
1482
|
+
result = data[offset, size].unpack(PACK_CHAR).first
|
1483
|
+
when :timestamp
|
1484
|
+
size = 8
|
1485
|
+
result = Time.at(data[offset, size].unpack(PACK_UINT32_X2).last)
|
1486
|
+
when :table
|
1487
|
+
size = 4 + data[offset, 4].unpack(PACK_UINT32)[0]
|
1488
|
+
result = Table.decode(data[offset, size])
|
1489
|
+
end
|
1490
|
+
properties[name] = result
|
1491
|
+
offset += size
|
1492
|
+
end
|
1493
|
+
end
|
1494
|
+
|
1495
|
+
properties
|
1496
|
+
end
|
1497
|
+
|
1498
|
+
class Qos < Protocol::Method
|
1499
|
+
@name = "basic.qos"
|
1500
|
+
@method_id = 10
|
1501
|
+
@index = 0x003C000A # 60, 10, 3932170
|
1502
|
+
@packed_indexes = [60, 10].pack(PACK_UINT16_X2).freeze
|
1503
|
+
|
1504
|
+
def self.has_content?
|
1505
|
+
false
|
1506
|
+
end
|
1507
|
+
|
1508
|
+
# @return
|
1509
|
+
# ["prefetch_size = false", "prefetch_count = false", "global = false"]
|
1510
|
+
def self.encode(channel, prefetch_size, prefetch_count, global)
|
1511
|
+
buffer = ""
|
1512
|
+
buffer << @packed_indexes
|
1513
|
+
buffer << [prefetch_size].pack(PACK_UINT32)
|
1514
|
+
buffer << [prefetch_count].pack(PACK_UINT16)
|
1515
|
+
bit_buffer = 0
|
1516
|
+
bit_buffer = bit_buffer | (1 << 0) if global
|
1517
|
+
buffer << [bit_buffer].pack(PACK_CHAR)
|
1518
|
+
MethodFrame.new(buffer, channel)
|
1519
|
+
end
|
1520
|
+
end
|
1521
|
+
|
1522
|
+
class QosOk < Protocol::Method
|
1523
|
+
@name = "basic.qos-ok"
|
1524
|
+
@method_id = 11
|
1525
|
+
@index = 0x003C000B # 60, 11, 3932171
|
1526
|
+
@packed_indexes = [60, 11].pack(PACK_UINT16_X2).freeze
|
1527
|
+
|
1528
|
+
# @return
|
1529
|
+
def self.decode(data)
|
1530
|
+
offset = 0
|
1531
|
+
self.new()
|
1532
|
+
end
|
1533
|
+
|
1534
|
+
def initialize()
|
1535
|
+
end
|
1536
|
+
|
1537
|
+
def self.has_content?
|
1538
|
+
false
|
1539
|
+
end
|
1540
|
+
end
|
1541
|
+
|
1542
|
+
class Consume < Protocol::Method
|
1543
|
+
@name = "basic.consume"
|
1544
|
+
@method_id = 20
|
1545
|
+
@index = 0x003C0014 # 60, 20, 3932180
|
1546
|
+
@packed_indexes = [60, 20].pack(PACK_UINT16_X2).freeze
|
1547
|
+
|
1548
|
+
def self.has_content?
|
1549
|
+
false
|
1550
|
+
end
|
1551
|
+
|
1552
|
+
# @return
|
1553
|
+
# ["ticket = 0", "queue = EMPTY_STRING", "consumer_tag = EMPTY_STRING", "no_local = false", "no_ack = false", "exclusive = false", "nowait = false", "arguments = {}"]
|
1554
|
+
def self.encode(channel, queue, consumer_tag, no_local, no_ack, exclusive, nowait, arguments)
|
1555
|
+
ticket = 0
|
1556
|
+
buffer = ""
|
1557
|
+
buffer << @packed_indexes
|
1558
|
+
buffer << [ticket].pack(PACK_UINT16)
|
1559
|
+
buffer << queue.bytesize.chr
|
1560
|
+
buffer << queue
|
1561
|
+
buffer << consumer_tag.bytesize.chr
|
1562
|
+
buffer << consumer_tag
|
1563
|
+
bit_buffer = 0
|
1564
|
+
bit_buffer = bit_buffer | (1 << 0) if no_local
|
1565
|
+
bit_buffer = bit_buffer | (1 << 1) if no_ack
|
1566
|
+
bit_buffer = bit_buffer | (1 << 2) if exclusive
|
1567
|
+
bit_buffer = bit_buffer | (1 << 3) if nowait
|
1568
|
+
buffer << [bit_buffer].pack(PACK_CHAR)
|
1569
|
+
buffer << AMQ::Protocol::Table.encode(arguments)
|
1570
|
+
MethodFrame.new(buffer, channel)
|
1571
|
+
end
|
1572
|
+
end
|
1573
|
+
|
1574
|
+
class ConsumeOk < Protocol::Method
|
1575
|
+
@name = "basic.consume-ok"
|
1576
|
+
@method_id = 21
|
1577
|
+
@index = 0x003C0015 # 60, 21, 3932181
|
1578
|
+
@packed_indexes = [60, 21].pack(PACK_UINT16_X2).freeze
|
1579
|
+
|
1580
|
+
# @return
|
1581
|
+
def self.decode(data)
|
1582
|
+
offset = 0
|
1583
|
+
length = data[offset, 1].unpack(PACK_CHAR).first
|
1584
|
+
offset += 1
|
1585
|
+
consumer_tag = data[offset, length]
|
1586
|
+
offset += length
|
1587
|
+
self.new(consumer_tag)
|
1588
|
+
end
|
1589
|
+
|
1590
|
+
attr_reader :consumer_tag
|
1591
|
+
def initialize(consumer_tag)
|
1592
|
+
@consumer_tag = consumer_tag
|
1593
|
+
end
|
1594
|
+
|
1595
|
+
def self.has_content?
|
1596
|
+
false
|
1597
|
+
end
|
1598
|
+
end
|
1599
|
+
|
1600
|
+
class Cancel < Protocol::Method
|
1601
|
+
@name = "basic.cancel"
|
1602
|
+
@method_id = 30
|
1603
|
+
@index = 0x003C001E # 60, 30, 3932190
|
1604
|
+
@packed_indexes = [60, 30].pack(PACK_UINT16_X2).freeze
|
1605
|
+
|
1606
|
+
def self.has_content?
|
1607
|
+
false
|
1608
|
+
end
|
1609
|
+
|
1610
|
+
# @return
|
1611
|
+
# ["consumer_tag = nil", "nowait = false"]
|
1612
|
+
def self.encode(channel, consumer_tag, nowait)
|
1613
|
+
buffer = ""
|
1614
|
+
buffer << @packed_indexes
|
1615
|
+
buffer << consumer_tag.bytesize.chr
|
1616
|
+
buffer << consumer_tag
|
1617
|
+
bit_buffer = 0
|
1618
|
+
bit_buffer = bit_buffer | (1 << 0) if nowait
|
1619
|
+
buffer << [bit_buffer].pack(PACK_CHAR)
|
1620
|
+
MethodFrame.new(buffer, channel)
|
1621
|
+
end
|
1622
|
+
end
|
1623
|
+
|
1624
|
+
class CancelOk < Protocol::Method
|
1625
|
+
@name = "basic.cancel-ok"
|
1626
|
+
@method_id = 31
|
1627
|
+
@index = 0x003C001F # 60, 31, 3932191
|
1628
|
+
@packed_indexes = [60, 31].pack(PACK_UINT16_X2).freeze
|
1629
|
+
|
1630
|
+
# @return
|
1631
|
+
def self.decode(data)
|
1632
|
+
offset = 0
|
1633
|
+
length = data[offset, 1].unpack(PACK_CHAR).first
|
1634
|
+
offset += 1
|
1635
|
+
consumer_tag = data[offset, length]
|
1636
|
+
offset += length
|
1637
|
+
self.new(consumer_tag)
|
1638
|
+
end
|
1639
|
+
|
1640
|
+
attr_reader :consumer_tag
|
1641
|
+
def initialize(consumer_tag)
|
1642
|
+
@consumer_tag = consumer_tag
|
1643
|
+
end
|
1644
|
+
|
1645
|
+
def self.has_content?
|
1646
|
+
false
|
1647
|
+
end
|
1648
|
+
end
|
1649
|
+
|
1650
|
+
class Publish < Protocol::Method
|
1651
|
+
@name = "basic.publish"
|
1652
|
+
@method_id = 40
|
1653
|
+
@index = 0x003C0028 # 60, 40, 3932200
|
1654
|
+
@packed_indexes = [60, 40].pack(PACK_UINT16_X2).freeze
|
1655
|
+
|
1656
|
+
def self.has_content?
|
1657
|
+
true
|
1658
|
+
end
|
1659
|
+
|
1660
|
+
# @return
|
1661
|
+
# ["ticket = 0", "exchange = EMPTY_STRING", "routing_key = EMPTY_STRING", "mandatory = false", "immediate = false", "user_headers = nil", "payload = """, "frame_size = nil"]
|
1662
|
+
def self.encode(channel, payload, user_headers, exchange, routing_key, mandatory, immediate, frame_size)
|
1663
|
+
ticket = 0
|
1664
|
+
buffer = ""
|
1665
|
+
buffer << @packed_indexes
|
1666
|
+
buffer << [ticket].pack(PACK_UINT16)
|
1667
|
+
buffer << exchange.bytesize.chr
|
1668
|
+
buffer << exchange
|
1669
|
+
buffer << routing_key.bytesize.chr
|
1670
|
+
buffer << routing_key
|
1671
|
+
bit_buffer = 0
|
1672
|
+
bit_buffer = bit_buffer | (1 << 0) if mandatory
|
1673
|
+
bit_buffer = bit_buffer | (1 << 1) if immediate
|
1674
|
+
buffer << [bit_buffer].pack(PACK_CHAR)
|
1675
|
+
frames = [MethodFrame.new(buffer, channel)]
|
1676
|
+
properties, headers = self.split_headers(user_headers)
|
1677
|
+
# TODO: what shall I do with the headers?
|
1678
|
+
if properties.nil? or properties.empty?
|
1679
|
+
raise RuntimeError.new("Properties can not be empty!") # TODO: or can they?
|
1680
|
+
end
|
1681
|
+
properties_payload = Basic.encode_properties(payload.bytesize, properties)
|
1682
|
+
frames << HeaderFrame.new(properties_payload, channel)
|
1683
|
+
frames + self.encode_body(payload, channel, frame_size)
|
1684
|
+
end
|
1685
|
+
end
|
1686
|
+
|
1687
|
+
class Return < Protocol::Method
|
1688
|
+
@name = "basic.return"
|
1689
|
+
@method_id = 50
|
1690
|
+
@index = 0x003C0032 # 60, 50, 3932210
|
1691
|
+
@packed_indexes = [60, 50].pack(PACK_UINT16_X2).freeze
|
1692
|
+
|
1693
|
+
# @return
|
1694
|
+
def self.decode(data)
|
1695
|
+
offset = 0
|
1696
|
+
reply_code = data[offset, 2].unpack(PACK_UINT16).first
|
1697
|
+
offset += 2
|
1698
|
+
length = data[offset, 1].unpack(PACK_CHAR).first
|
1699
|
+
offset += 1
|
1700
|
+
reply_text = data[offset, length]
|
1701
|
+
offset += length
|
1702
|
+
length = data[offset, 1].unpack(PACK_CHAR).first
|
1703
|
+
offset += 1
|
1704
|
+
exchange = data[offset, length]
|
1705
|
+
offset += length
|
1706
|
+
length = data[offset, 1].unpack(PACK_CHAR).first
|
1707
|
+
offset += 1
|
1708
|
+
routing_key = data[offset, length]
|
1709
|
+
offset += length
|
1710
|
+
self.new(reply_code, reply_text, exchange, routing_key)
|
1711
|
+
end
|
1712
|
+
|
1713
|
+
attr_reader :reply_code, :reply_text, :exchange, :routing_key
|
1714
|
+
def initialize(reply_code, reply_text, exchange, routing_key)
|
1715
|
+
@reply_code = reply_code
|
1716
|
+
@reply_text = reply_text
|
1717
|
+
@exchange = exchange
|
1718
|
+
@routing_key = routing_key
|
1719
|
+
end
|
1720
|
+
|
1721
|
+
def self.has_content?
|
1722
|
+
true
|
1723
|
+
end
|
1724
|
+
end
|
1725
|
+
|
1726
|
+
class Deliver < Protocol::Method
|
1727
|
+
@name = "basic.deliver"
|
1728
|
+
@method_id = 60
|
1729
|
+
@index = 0x003C003C # 60, 60, 3932220
|
1730
|
+
@packed_indexes = [60, 60].pack(PACK_UINT16_X2).freeze
|
1731
|
+
|
1732
|
+
# @return
|
1733
|
+
def self.decode(data)
|
1734
|
+
offset = 0
|
1735
|
+
length = data[offset, 1].unpack(PACK_CHAR).first
|
1736
|
+
offset += 1
|
1737
|
+
consumer_tag = data[offset, length]
|
1738
|
+
offset += length
|
1739
|
+
delivery_tag = AMQ::Hacks.unpack_64_big_endian(data[offset, 8]).first
|
1740
|
+
offset += 8
|
1741
|
+
bit_buffer = data[offset, 1].unpack(PACK_CHAR).first
|
1742
|
+
offset += 1
|
1743
|
+
redelivered = (bit_buffer & (1 << 0)) != 0
|
1744
|
+
length = data[offset, 1].unpack(PACK_CHAR).first
|
1745
|
+
offset += 1
|
1746
|
+
exchange = data[offset, length]
|
1747
|
+
offset += length
|
1748
|
+
length = data[offset, 1].unpack(PACK_CHAR).first
|
1749
|
+
offset += 1
|
1750
|
+
routing_key = data[offset, length]
|
1751
|
+
offset += length
|
1752
|
+
self.new(consumer_tag, delivery_tag, redelivered, exchange, routing_key)
|
1753
|
+
end
|
1754
|
+
|
1755
|
+
attr_reader :consumer_tag, :delivery_tag, :redelivered, :exchange, :routing_key
|
1756
|
+
def initialize(consumer_tag, delivery_tag, redelivered, exchange, routing_key)
|
1757
|
+
@consumer_tag = consumer_tag
|
1758
|
+
@delivery_tag = delivery_tag
|
1759
|
+
@redelivered = redelivered
|
1760
|
+
@exchange = exchange
|
1761
|
+
@routing_key = routing_key
|
1762
|
+
end
|
1763
|
+
|
1764
|
+
def self.has_content?
|
1765
|
+
true
|
1766
|
+
end
|
1767
|
+
end
|
1768
|
+
|
1769
|
+
class Get < Protocol::Method
|
1770
|
+
@name = "basic.get"
|
1771
|
+
@method_id = 70
|
1772
|
+
@index = 0x003C0046 # 60, 70, 3932230
|
1773
|
+
@packed_indexes = [60, 70].pack(PACK_UINT16_X2).freeze
|
1774
|
+
|
1775
|
+
def self.has_content?
|
1776
|
+
false
|
1777
|
+
end
|
1778
|
+
|
1779
|
+
# @return
|
1780
|
+
# ["ticket = 0", "queue = EMPTY_STRING", "no_ack = false"]
|
1781
|
+
def self.encode(channel, queue, no_ack)
|
1782
|
+
ticket = 0
|
1783
|
+
buffer = ""
|
1784
|
+
buffer << @packed_indexes
|
1785
|
+
buffer << [ticket].pack(PACK_UINT16)
|
1786
|
+
buffer << queue.bytesize.chr
|
1787
|
+
buffer << queue
|
1788
|
+
bit_buffer = 0
|
1789
|
+
bit_buffer = bit_buffer | (1 << 0) if no_ack
|
1790
|
+
buffer << [bit_buffer].pack(PACK_CHAR)
|
1791
|
+
MethodFrame.new(buffer, channel)
|
1792
|
+
end
|
1793
|
+
end
|
1794
|
+
|
1795
|
+
class GetOk < Protocol::Method
|
1796
|
+
@name = "basic.get-ok"
|
1797
|
+
@method_id = 71
|
1798
|
+
@index = 0x003C0047 # 60, 71, 3932231
|
1799
|
+
@packed_indexes = [60, 71].pack(PACK_UINT16_X2).freeze
|
1800
|
+
|
1801
|
+
# @return
|
1802
|
+
def self.decode(data)
|
1803
|
+
offset = 0
|
1804
|
+
delivery_tag = AMQ::Hacks.unpack_64_big_endian(data[offset, 8]).first
|
1805
|
+
offset += 8
|
1806
|
+
bit_buffer = data[offset, 1].unpack(PACK_CHAR).first
|
1807
|
+
offset += 1
|
1808
|
+
redelivered = (bit_buffer & (1 << 0)) != 0
|
1809
|
+
length = data[offset, 1].unpack(PACK_CHAR).first
|
1810
|
+
offset += 1
|
1811
|
+
exchange = data[offset, length]
|
1812
|
+
offset += length
|
1813
|
+
length = data[offset, 1].unpack(PACK_CHAR).first
|
1814
|
+
offset += 1
|
1815
|
+
routing_key = data[offset, length]
|
1816
|
+
offset += length
|
1817
|
+
message_count = data[offset, 4].unpack(PACK_UINT32).first
|
1818
|
+
offset += 4
|
1819
|
+
self.new(delivery_tag, redelivered, exchange, routing_key, message_count)
|
1820
|
+
end
|
1821
|
+
|
1822
|
+
attr_reader :delivery_tag, :redelivered, :exchange, :routing_key, :message_count
|
1823
|
+
def initialize(delivery_tag, redelivered, exchange, routing_key, message_count)
|
1824
|
+
@delivery_tag = delivery_tag
|
1825
|
+
@redelivered = redelivered
|
1826
|
+
@exchange = exchange
|
1827
|
+
@routing_key = routing_key
|
1828
|
+
@message_count = message_count
|
1829
|
+
end
|
1830
|
+
|
1831
|
+
def self.has_content?
|
1832
|
+
true
|
1833
|
+
end
|
1834
|
+
end
|
1835
|
+
|
1836
|
+
class GetEmpty < Protocol::Method
|
1837
|
+
@name = "basic.get-empty"
|
1838
|
+
@method_id = 72
|
1839
|
+
@index = 0x003C0048 # 60, 72, 3932232
|
1840
|
+
@packed_indexes = [60, 72].pack(PACK_UINT16_X2).freeze
|
1841
|
+
|
1842
|
+
# @return
|
1843
|
+
def self.decode(data)
|
1844
|
+
offset = 0
|
1845
|
+
length = data[offset, 1].unpack(PACK_CHAR).first
|
1846
|
+
offset += 1
|
1847
|
+
cluster_id = data[offset, length]
|
1848
|
+
offset += length
|
1849
|
+
self.new(cluster_id)
|
1850
|
+
end
|
1851
|
+
|
1852
|
+
attr_reader :cluster_id
|
1853
|
+
def initialize(cluster_id)
|
1854
|
+
@cluster_id = cluster_id
|
1855
|
+
end
|
1856
|
+
|
1857
|
+
def self.has_content?
|
1858
|
+
false
|
1859
|
+
end
|
1860
|
+
end
|
1861
|
+
|
1862
|
+
class Ack < Protocol::Method
|
1863
|
+
@name = "basic.ack"
|
1864
|
+
@method_id = 80
|
1865
|
+
@index = 0x003C0050 # 60, 80, 3932240
|
1866
|
+
@packed_indexes = [60, 80].pack(PACK_UINT16_X2).freeze
|
1867
|
+
|
1868
|
+
# @return
|
1869
|
+
def self.decode(data)
|
1870
|
+
offset = 0
|
1871
|
+
delivery_tag = AMQ::Hacks.unpack_64_big_endian(data[offset, 8]).first
|
1872
|
+
offset += 8
|
1873
|
+
bit_buffer = data[offset, 1].unpack(PACK_CHAR).first
|
1874
|
+
offset += 1
|
1875
|
+
multiple = (bit_buffer & (1 << 0)) != 0
|
1876
|
+
self.new(delivery_tag, multiple)
|
1877
|
+
end
|
1878
|
+
|
1879
|
+
attr_reader :delivery_tag, :multiple
|
1880
|
+
def initialize(delivery_tag, multiple)
|
1881
|
+
@delivery_tag = delivery_tag
|
1882
|
+
@multiple = multiple
|
1883
|
+
end
|
1884
|
+
|
1885
|
+
def self.has_content?
|
1886
|
+
false
|
1887
|
+
end
|
1888
|
+
|
1889
|
+
# @return
|
1890
|
+
# ["delivery_tag = false", "multiple = false"]
|
1891
|
+
def self.encode(channel, delivery_tag, multiple)
|
1892
|
+
buffer = ""
|
1893
|
+
buffer << @packed_indexes
|
1894
|
+
buffer << AMQ::Hacks.pack_64_big_endian(delivery_tag)
|
1895
|
+
bit_buffer = 0
|
1896
|
+
bit_buffer = bit_buffer | (1 << 0) if multiple
|
1897
|
+
buffer << [bit_buffer].pack(PACK_CHAR)
|
1898
|
+
MethodFrame.new(buffer, channel)
|
1899
|
+
end
|
1900
|
+
end
|
1901
|
+
|
1902
|
+
class Reject < Protocol::Method
|
1903
|
+
@name = "basic.reject"
|
1904
|
+
@method_id = 90
|
1905
|
+
@index = 0x003C005A # 60, 90, 3932250
|
1906
|
+
@packed_indexes = [60, 90].pack(PACK_UINT16_X2).freeze
|
1907
|
+
|
1908
|
+
def self.has_content?
|
1909
|
+
false
|
1910
|
+
end
|
1911
|
+
|
1912
|
+
# @return
|
1913
|
+
# ["delivery_tag = nil", "requeue = true"]
|
1914
|
+
def self.encode(channel, delivery_tag, requeue)
|
1915
|
+
buffer = ""
|
1916
|
+
buffer << @packed_indexes
|
1917
|
+
buffer << AMQ::Hacks.pack_64_big_endian(delivery_tag)
|
1918
|
+
bit_buffer = 0
|
1919
|
+
bit_buffer = bit_buffer | (1 << 0) if requeue
|
1920
|
+
buffer << [bit_buffer].pack(PACK_CHAR)
|
1921
|
+
MethodFrame.new(buffer, channel)
|
1922
|
+
end
|
1923
|
+
end
|
1924
|
+
|
1925
|
+
class RecoverAsync < Protocol::Method
|
1926
|
+
@name = "basic.recover-async"
|
1927
|
+
@method_id = 100
|
1928
|
+
@index = 0x003C0064 # 60, 100, 3932260
|
1929
|
+
@packed_indexes = [60, 100].pack(PACK_UINT16_X2).freeze
|
1930
|
+
|
1931
|
+
def self.has_content?
|
1932
|
+
false
|
1933
|
+
end
|
1934
|
+
|
1935
|
+
# @return
|
1936
|
+
# ["requeue = false"]
|
1937
|
+
def self.encode(channel, requeue)
|
1938
|
+
buffer = ""
|
1939
|
+
buffer << @packed_indexes
|
1940
|
+
bit_buffer = 0
|
1941
|
+
bit_buffer = bit_buffer | (1 << 0) if requeue
|
1942
|
+
buffer << [bit_buffer].pack(PACK_CHAR)
|
1943
|
+
MethodFrame.new(buffer, channel)
|
1944
|
+
end
|
1945
|
+
end
|
1946
|
+
|
1947
|
+
class Recover < Protocol::Method
|
1948
|
+
@name = "basic.recover"
|
1949
|
+
@method_id = 110
|
1950
|
+
@index = 0x003C006E # 60, 110, 3932270
|
1951
|
+
@packed_indexes = [60, 110].pack(PACK_UINT16_X2).freeze
|
1952
|
+
|
1953
|
+
def self.has_content?
|
1954
|
+
false
|
1955
|
+
end
|
1956
|
+
|
1957
|
+
# @return
|
1958
|
+
# ["requeue = false"]
|
1959
|
+
def self.encode(channel, requeue)
|
1960
|
+
buffer = ""
|
1961
|
+
buffer << @packed_indexes
|
1962
|
+
bit_buffer = 0
|
1963
|
+
bit_buffer = bit_buffer | (1 << 0) if requeue
|
1964
|
+
buffer << [bit_buffer].pack(PACK_CHAR)
|
1965
|
+
MethodFrame.new(buffer, channel)
|
1966
|
+
end
|
1967
|
+
end
|
1968
|
+
|
1969
|
+
class RecoverOk < Protocol::Method
|
1970
|
+
@name = "basic.recover-ok"
|
1971
|
+
@method_id = 111
|
1972
|
+
@index = 0x003C006F # 60, 111, 3932271
|
1973
|
+
@packed_indexes = [60, 111].pack(PACK_UINT16_X2).freeze
|
1974
|
+
|
1975
|
+
# @return
|
1976
|
+
def self.decode(data)
|
1977
|
+
offset = 0
|
1978
|
+
self.new()
|
1979
|
+
end
|
1980
|
+
|
1981
|
+
def initialize()
|
1982
|
+
end
|
1983
|
+
|
1984
|
+
def self.has_content?
|
1985
|
+
false
|
1986
|
+
end
|
1987
|
+
end
|
1988
|
+
|
1989
|
+
class Nack < Protocol::Method
|
1990
|
+
@name = "basic.nack"
|
1991
|
+
@method_id = 120
|
1992
|
+
@index = 0x003C0078 # 60, 120, 3932280
|
1993
|
+
@packed_indexes = [60, 120].pack(PACK_UINT16_X2).freeze
|
1994
|
+
|
1995
|
+
# @return
|
1996
|
+
def self.decode(data)
|
1997
|
+
offset = 0
|
1998
|
+
delivery_tag = AMQ::Hacks.unpack_64_big_endian(data[offset, 8]).first
|
1999
|
+
offset += 8
|
2000
|
+
bit_buffer = data[offset, 1].unpack(PACK_CHAR).first
|
2001
|
+
offset += 1
|
2002
|
+
multiple = (bit_buffer & (1 << 0)) != 0
|
2003
|
+
requeue = (bit_buffer & (1 << 1)) != 0
|
2004
|
+
self.new(delivery_tag, multiple, requeue)
|
2005
|
+
end
|
2006
|
+
|
2007
|
+
attr_reader :delivery_tag, :multiple, :requeue
|
2008
|
+
def initialize(delivery_tag, multiple, requeue)
|
2009
|
+
@delivery_tag = delivery_tag
|
2010
|
+
@multiple = multiple
|
2011
|
+
@requeue = requeue
|
2012
|
+
end
|
2013
|
+
|
2014
|
+
def self.has_content?
|
2015
|
+
false
|
2016
|
+
end
|
2017
|
+
|
2018
|
+
# @return
|
2019
|
+
# ["delivery_tag = false", "multiple = false", "requeue = true"]
|
2020
|
+
def self.encode(channel, delivery_tag, multiple, requeue)
|
2021
|
+
buffer = ""
|
2022
|
+
buffer << @packed_indexes
|
2023
|
+
buffer << AMQ::Hacks.pack_64_big_endian(delivery_tag)
|
2024
|
+
bit_buffer = 0
|
2025
|
+
bit_buffer = bit_buffer | (1 << 0) if multiple
|
2026
|
+
bit_buffer = bit_buffer | (1 << 1) if requeue
|
2027
|
+
buffer << [bit_buffer].pack(PACK_CHAR)
|
2028
|
+
MethodFrame.new(buffer, channel)
|
2029
|
+
end
|
2030
|
+
end
|
2031
|
+
end
|
2032
|
+
|
2033
|
+
class Tx < Protocol::Class
|
2034
|
+
@name = "tx"
|
2035
|
+
@method_id = 90
|
2036
|
+
|
2037
|
+
class Select < Protocol::Method
|
2038
|
+
@name = "tx.select"
|
2039
|
+
@method_id = 10
|
2040
|
+
@index = 0x005A000A # 90, 10, 5898250
|
2041
|
+
@packed_indexes = [90, 10].pack(PACK_UINT16_X2).freeze
|
2042
|
+
|
2043
|
+
def self.has_content?
|
2044
|
+
false
|
2045
|
+
end
|
2046
|
+
|
2047
|
+
# @return
|
2048
|
+
# []
|
2049
|
+
def self.encode(channel)
|
2050
|
+
buffer = ""
|
2051
|
+
buffer << @packed_indexes
|
2052
|
+
MethodFrame.new(buffer, channel)
|
2053
|
+
end
|
2054
|
+
end
|
2055
|
+
|
2056
|
+
class SelectOk < Protocol::Method
|
2057
|
+
@name = "tx.select-ok"
|
2058
|
+
@method_id = 11
|
2059
|
+
@index = 0x005A000B # 90, 11, 5898251
|
2060
|
+
@packed_indexes = [90, 11].pack(PACK_UINT16_X2).freeze
|
2061
|
+
|
2062
|
+
# @return
|
2063
|
+
def self.decode(data)
|
2064
|
+
offset = 0
|
2065
|
+
self.new()
|
2066
|
+
end
|
2067
|
+
|
2068
|
+
def initialize()
|
2069
|
+
end
|
2070
|
+
|
2071
|
+
def self.has_content?
|
2072
|
+
false
|
2073
|
+
end
|
2074
|
+
end
|
2075
|
+
|
2076
|
+
class Commit < Protocol::Method
|
2077
|
+
@name = "tx.commit"
|
2078
|
+
@method_id = 20
|
2079
|
+
@index = 0x005A0014 # 90, 20, 5898260
|
2080
|
+
@packed_indexes = [90, 20].pack(PACK_UINT16_X2).freeze
|
2081
|
+
|
2082
|
+
def self.has_content?
|
2083
|
+
false
|
2084
|
+
end
|
2085
|
+
|
2086
|
+
# @return
|
2087
|
+
# []
|
2088
|
+
def self.encode(channel)
|
2089
|
+
buffer = ""
|
2090
|
+
buffer << @packed_indexes
|
2091
|
+
MethodFrame.new(buffer, channel)
|
2092
|
+
end
|
2093
|
+
end
|
2094
|
+
|
2095
|
+
class CommitOk < Protocol::Method
|
2096
|
+
@name = "tx.commit-ok"
|
2097
|
+
@method_id = 21
|
2098
|
+
@index = 0x005A0015 # 90, 21, 5898261
|
2099
|
+
@packed_indexes = [90, 21].pack(PACK_UINT16_X2).freeze
|
2100
|
+
|
2101
|
+
# @return
|
2102
|
+
def self.decode(data)
|
2103
|
+
offset = 0
|
2104
|
+
self.new()
|
2105
|
+
end
|
2106
|
+
|
2107
|
+
def initialize()
|
2108
|
+
end
|
2109
|
+
|
2110
|
+
def self.has_content?
|
2111
|
+
false
|
2112
|
+
end
|
2113
|
+
end
|
2114
|
+
|
2115
|
+
class Rollback < Protocol::Method
|
2116
|
+
@name = "tx.rollback"
|
2117
|
+
@method_id = 30
|
2118
|
+
@index = 0x005A001E # 90, 30, 5898270
|
2119
|
+
@packed_indexes = [90, 30].pack(PACK_UINT16_X2).freeze
|
2120
|
+
|
2121
|
+
def self.has_content?
|
2122
|
+
false
|
2123
|
+
end
|
2124
|
+
|
2125
|
+
# @return
|
2126
|
+
# []
|
2127
|
+
def self.encode(channel)
|
2128
|
+
buffer = ""
|
2129
|
+
buffer << @packed_indexes
|
2130
|
+
MethodFrame.new(buffer, channel)
|
2131
|
+
end
|
2132
|
+
end
|
2133
|
+
|
2134
|
+
class RollbackOk < Protocol::Method
|
2135
|
+
@name = "tx.rollback-ok"
|
2136
|
+
@method_id = 31
|
2137
|
+
@index = 0x005A001F # 90, 31, 5898271
|
2138
|
+
@packed_indexes = [90, 31].pack(PACK_UINT16_X2).freeze
|
2139
|
+
|
2140
|
+
# @return
|
2141
|
+
def self.decode(data)
|
2142
|
+
offset = 0
|
2143
|
+
self.new()
|
2144
|
+
end
|
2145
|
+
|
2146
|
+
def initialize()
|
2147
|
+
end
|
2148
|
+
|
2149
|
+
def self.has_content?
|
2150
|
+
false
|
2151
|
+
end
|
2152
|
+
end
|
2153
|
+
end
|
2154
|
+
|
2155
|
+
class Confirm < Protocol::Class
|
2156
|
+
@name = "confirm"
|
2157
|
+
@method_id = 85
|
2158
|
+
|
2159
|
+
class Select < Protocol::Method
|
2160
|
+
@name = "confirm.select"
|
2161
|
+
@method_id = 10
|
2162
|
+
@index = 0x0055000A # 85, 10, 5570570
|
2163
|
+
@packed_indexes = [85, 10].pack(PACK_UINT16_X2).freeze
|
2164
|
+
|
2165
|
+
# @return
|
2166
|
+
def self.decode(data)
|
2167
|
+
offset = 0
|
2168
|
+
bit_buffer = data[offset, 1].unpack(PACK_CHAR).first
|
2169
|
+
offset += 1
|
2170
|
+
nowait = (bit_buffer & (1 << 0)) != 0
|
2171
|
+
self.new(nowait)
|
2172
|
+
end
|
2173
|
+
|
2174
|
+
attr_reader :nowait
|
2175
|
+
def initialize(nowait)
|
2176
|
+
@nowait = nowait
|
2177
|
+
end
|
2178
|
+
|
2179
|
+
def self.has_content?
|
2180
|
+
false
|
2181
|
+
end
|
2182
|
+
|
2183
|
+
# @return
|
2184
|
+
# ["nowait = false"]
|
2185
|
+
def self.encode(channel, nowait)
|
2186
|
+
buffer = ""
|
2187
|
+
buffer << @packed_indexes
|
2188
|
+
bit_buffer = 0
|
2189
|
+
bit_buffer = bit_buffer | (1 << 0) if nowait
|
2190
|
+
buffer << [bit_buffer].pack(PACK_CHAR)
|
2191
|
+
MethodFrame.new(buffer, channel)
|
2192
|
+
end
|
2193
|
+
end
|
2194
|
+
|
2195
|
+
class SelectOk < Protocol::Method
|
2196
|
+
@name = "confirm.select-ok"
|
2197
|
+
@method_id = 11
|
2198
|
+
@index = 0x0055000B # 85, 11, 5570571
|
2199
|
+
@packed_indexes = [85, 11].pack(PACK_UINT16_X2).freeze
|
2200
|
+
|
2201
|
+
# @return
|
2202
|
+
def self.decode(data)
|
2203
|
+
offset = 0
|
2204
|
+
self.new()
|
2205
|
+
end
|
2206
|
+
|
2207
|
+
def initialize()
|
2208
|
+
end
|
2209
|
+
|
2210
|
+
def self.has_content?
|
2211
|
+
false
|
2212
|
+
end
|
2213
|
+
|
2214
|
+
# @return
|
2215
|
+
# []
|
2216
|
+
def self.encode(channel)
|
2217
|
+
buffer = ""
|
2218
|
+
buffer << @packed_indexes
|
2219
|
+
MethodFrame.new(buffer, channel)
|
2220
|
+
end
|
2221
|
+
end
|
2222
|
+
end
|
2223
|
+
|
2224
|
+
METHODS = begin
|
2225
|
+
Method.methods.inject(Hash.new) do |hash, klass|
|
2226
|
+
hash.merge!(klass.index => klass)
|
2227
|
+
end
|
2228
|
+
end
|
2229
|
+
end
|
2230
|
+
end
|