amq-protocol 0.9.5 → 1.0.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -8,6 +8,7 @@ rvm:
8
8
  - 1.9.2
9
9
  - 1.9.3
10
10
  - ruby-head
11
+ - jruby-18mode
11
12
  - jruby-19mode
12
13
  - jruby-head
13
14
  notifications:
data/LICENSE CHANGED
@@ -1,5 +1,4 @@
1
1
  Copyright (c) 2010 – 2011 Jakub Šťastný aka Botanicus
2
- Copyright (c) 2011 - 2012 Michael S. Klishin
3
2
 
4
3
  Permission is hereby granted, free of charge, to any person obtaining
5
4
  a copy of this software and associated documentation files (the
@@ -1 +1 @@
1
- {"tx": {"select-ok": ["client"], "rollback": ["server"], "commit": ["server"], "rollback-ok": ["client"], "select": ["server"], "commit-ok": ["client"]}, "exchange": {"delete-ok": ["client"], "declare-ok": ["client"], "declare": ["server"], "delete": ["server"], "bind": ["server"], "bind-ok": ["client"], "unbind": ["server"], "unbind-ok": ["client"]}, "queue": {"unbind": ["server"], "unbind-ok": ["client"], "purge-ok": ["client"], "bind": ["server"], "purge": ["server"], "declare-ok": ["client"], "delete-ok": ["client"], "delete": ["server"], "declare": ["server"], "bind-ok": ["client"]}, "connection": {"secure": ["client"], "secure-ok": ["server"], "open-ok": ["client"], "close-ok": ["client", "server"], "start": ["client"], "tune": ["client"], "start-ok": ["server"], "close": ["client", "server"], "open": ["server"], "tune-ok": ["server"]}, "basic": {"qos": ["server"], "consume": ["server"], "reject": ["server"], "get": ["server"], "ack": ["client", "server"], "get-ok": ["client"], "consume-ok": ["client"], "deliver": ["client"], "recover-ok": ["client"], "publish": ["server"], "cancel": ["server", "client"], "recover-async": ["server"], "get-empty": ["client"], "qos-ok": ["client"], "return": ["client"], "recover": ["server"], "cancel-ok": ["client"]}, "channel": {"flow-ok": ["server", "client"], "flow": ["server", "client"], "open-ok": ["client"], "close-ok": ["client", "server"], "close": ["client", "server"], "open": ["server"]}}
1
+ {"tx": {"select-ok": ["client"], "rollback": ["server"], "commit": ["server"], "rollback-ok": ["client"], "select": ["server"], "commit-ok": ["client"]}, "exchange": {"delete-ok": ["client"], "declare-ok": ["client"], "declare": ["server"], "delete": ["server"], "bind": ["server"], "bind-ok": ["client"], "unbind": ["server"], "unbind-ok": ["client"]}, "queue": {"unbind": ["server"], "unbind-ok": ["client"], "purge-ok": ["client"], "bind": ["server"], "purge": ["server"], "declare-ok": ["client"], "delete-ok": ["client"], "delete": ["server"], "declare": ["server"], "bind-ok": ["client"]}, "connection": {"secure": ["client"], "secure-ok": ["server"], "open-ok": ["client"], "close-ok": ["client", "server"], "start": ["client"], "tune": ["client"], "start-ok": ["server"], "close": ["client", "server"], "open": ["server"], "tune-ok": ["server"]}, "basic": {"qos": ["server"], "consume": ["server"], "reject": ["server"], "get": ["server"], "ack": ["client", "server"], "get-ok": ["client"], "consume-ok": ["client"], "deliver": ["client"], "recover-ok": ["client"], "publish": ["server"], "cancel": ["server"], "recover-async": ["server"], "get-empty": ["client"], "qos-ok": ["client"], "return": ["client"], "recover": ["server"], "cancel-ok": ["client"]}, "channel": {"flow-ok": ["server", "client"], "flow": ["server", "client"], "open-ok": ["client"], "close-ok": ["client", "server"], "close": ["client", "server"], "open": ["server"]}}
data/codegen_helpers.py CHANGED
@@ -4,11 +4,11 @@ def genSingleEncode(spec, cValue, unresolved_domain):
4
4
  buffer = []
5
5
  type = spec.resolveDomain(unresolved_domain)
6
6
  if type == 'shortstr':
7
- buffer.append("buffer << %s.to_s.bytesize.chr" % (cValue,))
8
- buffer.append("buffer << %s.to_s" % (cValue,))
7
+ buffer.append("buffer << %s.bytesize.chr" % (cValue,))
8
+ buffer.append("buffer << %s" % (cValue,))
9
9
  elif type == 'longstr':
10
- buffer.append("buffer << [%s.to_s.bytesize].pack(PACK_UINT32)" % (cValue,))
11
- buffer.append("buffer << %s.to_s" % (cValue,))
10
+ buffer.append("buffer << [%s.bytesize].pack(PACK_UINT32)" % (cValue,))
11
+ buffer.append("buffer << %s" % (cValue,))
12
12
  elif type == 'octet':
13
13
  buffer.append("buffer << [%s].pack(PACK_CHAR)" % (cValue,))
14
14
  elif type == 'short':
@@ -87,9 +87,17 @@ def genSingleSimpleDecode(spec, field):
87
87
  type = spec.resolveDomain(unresolved_domain)
88
88
  buffer = []
89
89
  if type == 'shortstr':
90
- buffer.append("data.to_s")
90
+ # buffer.append("length = data.unpack(PACK_CHAR)[0]")
91
+ # buffer.append("result = data[offset..-1]")
92
+ # buffer.append("raise 'Bad size: #{length} expected, got #{result.bytesize}' if result.bytesize != length")
93
+ # buffer.append("result")
94
+ buffer.append("data")
91
95
  elif type == 'longstr':
92
- buffer.append("data.to_s")
96
+ # buffer.append("length = data.unpack(PACK_CHAR)[0]")
97
+ # buffer.append("result = data[offset..-1]")
98
+ # buffer.append("raise 'Bad size: #{length} expected, got #{result.bytesize}' if result.bytesize != length")
99
+ # buffer.append("result")
100
+ buffer.append("data")
93
101
  elif type == 'octet':
94
102
  buffer.append("data.unpack(PACK_CHAR).first")
95
103
  elif type == 'short':
@@ -17,17 +17,19 @@ module AMQ
17
17
  # caching
18
18
  EMPTY_STRING = "".freeze
19
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
- PACK_32BIT_FLOAT = "f".freeze
30
- PACK_64BIT_FLOAT = "d".freeze
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
+ PACK_32BIT_FLOAT = 'f'.freeze
30
+ PACK_64BIT_FLOAT = 'd'.freeze
31
+
32
+
31
33
 
32
34
  # @return [Array] Collection of subclasses of AMQ::Protocol::Class.
33
35
  def self.classes
@@ -168,8 +170,9 @@ module AMQ
168
170
  VALUE = 541
169
171
  end
170
172
 
171
- # We don"t instantiate the following classes,
172
- # as we don"t actually need any per-instance state.
173
+
174
+ # We don't instantiate the following classes,
175
+ # as we don't actually need any per-instance state.
173
176
  # Also, this is pretty low-level functionality,
174
177
  # hence it should have a reasonable performance.
175
178
  # As everyone knows, garbage collector in MRI performs
@@ -177,10 +180,10 @@ module AMQ
177
180
  # not creating any objects, but only use class as
178
181
  # a struct. Creating classes is quite expensive though,
179
182
  # but here the inheritance comes handy and mainly
180
- # as we can"t simply make a reference to a function,
181
- # we can"t use a hash or an object. I"ve been also
183
+ # as we can't simply make a reference to a function,
184
+ # we can't use a hash or an object. I've been also
182
185
  # considering to have just a bunch of methods, but
183
- # here"s the problem, that after we"d require this file,
186
+ # here's the problem, that after we'd require this file,
184
187
  # all these methods would become global which would
185
188
  # be a bad, bad thing to do.
186
189
  class Class
@@ -277,6 +280,8 @@ module AMQ
277
280
  @name = "connection"
278
281
  @method_id = 10
279
282
 
283
+
284
+
280
285
  class Start < Protocol::Method
281
286
  @name = "connection.start"
282
287
  @method_id = 10
@@ -316,6 +321,8 @@ module AMQ
316
321
  def self.has_content?
317
322
  false
318
323
  end
324
+
325
+
319
326
  end
320
327
 
321
328
  class StartOk < Protocol::Method
@@ -324,25 +331,27 @@ module AMQ
324
331
  @index = 0x000A000B # 10, 11, 655371
325
332
  @packed_indexes = [10, 11].pack(PACK_UINT16_X2).freeze
326
333
 
334
+
327
335
  def self.has_content?
328
336
  false
329
337
  end
330
338
 
331
339
  # @return
332
- # ["client_properties = nil", "mechanism = "PLAIN"", "response = nil", "locale = "en_US""]
340
+ # [u'client_properties = nil', u"mechanism = u'PLAIN'", u'response = nil', u"locale = u'en_US'"]
333
341
  def self.encode(client_properties, mechanism, response, locale)
334
342
  channel = 0
335
- buffer = ""
343
+ buffer = ''
336
344
  buffer << @packed_indexes
337
345
  buffer << AMQ::Protocol::Table.encode(client_properties)
338
- buffer << mechanism.to_s.bytesize.chr
339
- buffer << mechanism.to_s
340
- buffer << [response.to_s.bytesize].pack(PACK_UINT32)
341
- buffer << response.to_s
342
- buffer << locale.to_s.bytesize.chr
343
- buffer << locale.to_s
346
+ buffer << mechanism.bytesize.chr
347
+ buffer << mechanism
348
+ buffer << [response.bytesize].pack(PACK_UINT32)
349
+ buffer << response
350
+ buffer << locale.bytesize.chr
351
+ buffer << locale
344
352
  MethodFrame.new(buffer, channel)
345
353
  end
354
+
346
355
  end
347
356
 
348
357
  class Secure < Protocol::Method
@@ -369,6 +378,8 @@ module AMQ
369
378
  def self.has_content?
370
379
  false
371
380
  end
381
+
382
+
372
383
  end
373
384
 
374
385
  class SecureOk < Protocol::Method
@@ -377,20 +388,22 @@ module AMQ
377
388
  @index = 0x000A0015 # 10, 21, 655381
378
389
  @packed_indexes = [10, 21].pack(PACK_UINT16_X2).freeze
379
390
 
391
+
380
392
  def self.has_content?
381
393
  false
382
394
  end
383
395
 
384
396
  # @return
385
- # ["response = nil"]
397
+ # [u'response = nil']
386
398
  def self.encode(response)
387
399
  channel = 0
388
- buffer = ""
400
+ buffer = ''
389
401
  buffer << @packed_indexes
390
- buffer << [response.to_s.bytesize].pack(PACK_UINT32)
391
- buffer << response.to_s
402
+ buffer << [response.bytesize].pack(PACK_UINT32)
403
+ buffer << response
392
404
  MethodFrame.new(buffer, channel)
393
405
  end
406
+
394
407
  end
395
408
 
396
409
  class Tune < Protocol::Method
@@ -421,6 +434,8 @@ module AMQ
421
434
  def self.has_content?
422
435
  false
423
436
  end
437
+
438
+
424
439
  end
425
440
 
426
441
  class TuneOk < Protocol::Method
@@ -429,21 +444,23 @@ module AMQ
429
444
  @index = 0x000A001F # 10, 31, 655391
430
445
  @packed_indexes = [10, 31].pack(PACK_UINT16_X2).freeze
431
446
 
447
+
432
448
  def self.has_content?
433
449
  false
434
450
  end
435
451
 
436
452
  # @return
437
- # ["channel_max = false", "frame_max = false", "heartbeat = false"]
453
+ # [u'channel_max = false', u'frame_max = false', u'heartbeat = false']
438
454
  def self.encode(channel_max, frame_max, heartbeat)
439
455
  channel = 0
440
- buffer = ""
456
+ buffer = ''
441
457
  buffer << @packed_indexes
442
458
  buffer << [channel_max].pack(PACK_UINT16)
443
459
  buffer << [frame_max].pack(PACK_UINT32)
444
460
  buffer << [heartbeat].pack(PACK_UINT16)
445
461
  MethodFrame.new(buffer, channel)
446
462
  end
463
+
447
464
  end
448
465
 
449
466
  class Open < Protocol::Method
@@ -452,27 +469,29 @@ module AMQ
452
469
  @index = 0x000A0028 # 10, 40, 655400
453
470
  @packed_indexes = [10, 40].pack(PACK_UINT16_X2).freeze
454
471
 
472
+
455
473
  def self.has_content?
456
474
  false
457
475
  end
458
476
 
459
477
  # @return
460
- # ["virtual_host = "/"", "capabilities = EMPTY_STRING", "insist = false"]
478
+ # [u"virtual_host = u'/'", u'capabilities = EMPTY_STRING', u'insist = false']
461
479
  def self.encode(virtual_host)
462
480
  capabilities = EMPTY_STRING
463
481
  insist = false
464
482
  channel = 0
465
- buffer = ""
483
+ buffer = ''
466
484
  buffer << @packed_indexes
467
- buffer << virtual_host.to_s.bytesize.chr
468
- buffer << virtual_host.to_s
469
- buffer << capabilities.to_s.bytesize.chr
470
- buffer << capabilities.to_s
485
+ buffer << virtual_host.bytesize.chr
486
+ buffer << virtual_host
487
+ buffer << capabilities.bytesize.chr
488
+ buffer << capabilities
471
489
  bit_buffer = 0
472
490
  bit_buffer = bit_buffer | (1 << 0) if insist
473
491
  buffer << [bit_buffer].pack(PACK_CHAR)
474
492
  MethodFrame.new(buffer, channel)
475
493
  end
494
+
476
495
  end
477
496
 
478
497
  class OpenOk < Protocol::Method
@@ -499,6 +518,8 @@ module AMQ
499
518
  def self.has_content?
500
519
  false
501
520
  end
521
+
522
+
502
523
  end
503
524
 
504
525
  class Close < Protocol::Method
@@ -536,18 +557,19 @@ module AMQ
536
557
  end
537
558
 
538
559
  # @return
539
- # ["reply_code = nil", "reply_text = EMPTY_STRING", "class_id = nil", "method_id = nil"]
560
+ # [u'reply_code = nil', u'reply_text = EMPTY_STRING', u'class_id = nil', u'method_id = nil']
540
561
  def self.encode(reply_code, reply_text, class_id, method_id)
541
562
  channel = 0
542
- buffer = ""
563
+ buffer = ''
543
564
  buffer << @packed_indexes
544
565
  buffer << [reply_code].pack(PACK_UINT16)
545
- buffer << reply_text.to_s.bytesize.chr
546
- buffer << reply_text.to_s
566
+ buffer << reply_text.bytesize.chr
567
+ buffer << reply_text
547
568
  buffer << [class_id].pack(PACK_UINT16)
548
569
  buffer << [method_id].pack(PACK_UINT16)
549
570
  MethodFrame.new(buffer, channel)
550
571
  end
572
+
551
573
  end
552
574
 
553
575
  class CloseOk < Protocol::Method
@@ -573,36 +595,42 @@ module AMQ
573
595
  # []
574
596
  def self.encode()
575
597
  channel = 0
576
- buffer = ""
598
+ buffer = ''
577
599
  buffer << @packed_indexes
578
600
  MethodFrame.new(buffer, channel)
579
601
  end
602
+
580
603
  end
604
+
581
605
  end
582
606
 
583
607
  class Channel < Protocol::Class
584
608
  @name = "channel"
585
609
  @method_id = 20
586
610
 
611
+
612
+
587
613
  class Open < Protocol::Method
588
614
  @name = "channel.open"
589
615
  @method_id = 10
590
616
  @index = 0x0014000A # 20, 10, 1310730
591
617
  @packed_indexes = [20, 10].pack(PACK_UINT16_X2).freeze
592
618
 
619
+
593
620
  def self.has_content?
594
621
  false
595
622
  end
596
623
 
597
624
  # @return
598
- # ["out_of_band = EMPTY_STRING"]
625
+ # [u'out_of_band = EMPTY_STRING']
599
626
  def self.encode(channel, out_of_band)
600
- buffer = ""
627
+ buffer = ''
601
628
  buffer << @packed_indexes
602
- buffer << out_of_band.to_s.bytesize.chr
603
- buffer << out_of_band.to_s
629
+ buffer << out_of_band.bytesize.chr
630
+ buffer << out_of_band
604
631
  MethodFrame.new(buffer, channel)
605
632
  end
633
+
606
634
  end
607
635
 
608
636
  class OpenOk < Protocol::Method
@@ -629,6 +657,8 @@ module AMQ
629
657
  def self.has_content?
630
658
  false
631
659
  end
660
+
661
+
632
662
  end
633
663
 
634
664
  class Flow < Protocol::Method
@@ -656,15 +686,16 @@ module AMQ
656
686
  end
657
687
 
658
688
  # @return
659
- # ["active = nil"]
689
+ # [u'active = nil']
660
690
  def self.encode(channel, active)
661
- buffer = ""
691
+ buffer = ''
662
692
  buffer << @packed_indexes
663
693
  bit_buffer = 0
664
694
  bit_buffer = bit_buffer | (1 << 0) if active
665
695
  buffer << [bit_buffer].pack(PACK_CHAR)
666
696
  MethodFrame.new(buffer, channel)
667
697
  end
698
+
668
699
  end
669
700
 
670
701
  class FlowOk < Protocol::Method
@@ -692,15 +723,16 @@ module AMQ
692
723
  end
693
724
 
694
725
  # @return
695
- # ["active = nil"]
726
+ # [u'active = nil']
696
727
  def self.encode(channel, active)
697
- buffer = ""
728
+ buffer = ''
698
729
  buffer << @packed_indexes
699
730
  bit_buffer = 0
700
731
  bit_buffer = bit_buffer | (1 << 0) if active
701
732
  buffer << [bit_buffer].pack(PACK_CHAR)
702
733
  MethodFrame.new(buffer, channel)
703
734
  end
735
+
704
736
  end
705
737
 
706
738
  class Close < Protocol::Method
@@ -738,17 +770,18 @@ module AMQ
738
770
  end
739
771
 
740
772
  # @return
741
- # ["reply_code = nil", "reply_text = EMPTY_STRING", "class_id = nil", "method_id = nil"]
773
+ # [u'reply_code = nil', u'reply_text = EMPTY_STRING', u'class_id = nil', u'method_id = nil']
742
774
  def self.encode(channel, reply_code, reply_text, class_id, method_id)
743
- buffer = ""
775
+ buffer = ''
744
776
  buffer << @packed_indexes
745
777
  buffer << [reply_code].pack(PACK_UINT16)
746
- buffer << reply_text.to_s.bytesize.chr
747
- buffer << reply_text.to_s
778
+ buffer << reply_text.bytesize.chr
779
+ buffer << reply_text
748
780
  buffer << [class_id].pack(PACK_UINT16)
749
781
  buffer << [method_id].pack(PACK_UINT16)
750
782
  MethodFrame.new(buffer, channel)
751
783
  end
784
+
752
785
  end
753
786
 
754
787
  class CloseOk < Protocol::Method
@@ -773,38 +806,43 @@ module AMQ
773
806
  # @return
774
807
  # []
775
808
  def self.encode(channel)
776
- buffer = ""
809
+ buffer = ''
777
810
  buffer << @packed_indexes
778
811
  MethodFrame.new(buffer, channel)
779
812
  end
813
+
780
814
  end
815
+
781
816
  end
782
817
 
783
818
  class Exchange < Protocol::Class
784
819
  @name = "exchange"
785
820
  @method_id = 40
786
821
 
822
+
823
+
787
824
  class Declare < Protocol::Method
788
825
  @name = "exchange.declare"
789
826
  @method_id = 10
790
827
  @index = 0x0028000A # 40, 10, 2621450
791
828
  @packed_indexes = [40, 10].pack(PACK_UINT16_X2).freeze
792
829
 
830
+
793
831
  def self.has_content?
794
832
  false
795
833
  end
796
834
 
797
835
  # @return
798
- # ["ticket = 0", "exchange = nil", "type = "direct"", "passive = false", "durable = false", "auto_delete = false", "internal = false", "nowait = false", "arguments = {}"]
836
+ # [u'ticket = 0', u'exchange = nil', u"type = u'direct'", u'passive = false', u'durable = false', u'auto_delete = false', u'internal = false', u'nowait = false', u'arguments = {}']
799
837
  def self.encode(channel, exchange, type, passive, durable, auto_delete, internal, nowait, arguments)
800
838
  ticket = 0
801
- buffer = ""
839
+ buffer = ''
802
840
  buffer << @packed_indexes
803
841
  buffer << [ticket].pack(PACK_UINT16)
804
- buffer << exchange.to_s.bytesize.chr
805
- buffer << exchange.to_s
806
- buffer << type.to_s.bytesize.chr
807
- buffer << type.to_s
842
+ buffer << exchange.bytesize.chr
843
+ buffer << exchange
844
+ buffer << type.bytesize.chr
845
+ buffer << type
808
846
  bit_buffer = 0
809
847
  bit_buffer = bit_buffer | (1 << 0) if passive
810
848
  bit_buffer = bit_buffer | (1 << 1) if durable
@@ -815,6 +853,7 @@ module AMQ
815
853
  buffer << AMQ::Protocol::Table.encode(arguments)
816
854
  MethodFrame.new(buffer, channel)
817
855
  end
856
+
818
857
  end
819
858
 
820
859
  class DeclareOk < Protocol::Method
@@ -835,6 +874,8 @@ module AMQ
835
874
  def self.has_content?
836
875
  false
837
876
  end
877
+
878
+
838
879
  end
839
880
 
840
881
  class Delete < Protocol::Method
@@ -843,25 +884,27 @@ module AMQ
843
884
  @index = 0x00280014 # 40, 20, 2621460
844
885
  @packed_indexes = [40, 20].pack(PACK_UINT16_X2).freeze
845
886
 
887
+
846
888
  def self.has_content?
847
889
  false
848
890
  end
849
891
 
850
892
  # @return
851
- # ["ticket = 0", "exchange = nil", "if_unused = false", "nowait = false"]
893
+ # [u'ticket = 0', u'exchange = nil', u'if_unused = false', u'nowait = false']
852
894
  def self.encode(channel, exchange, if_unused, nowait)
853
895
  ticket = 0
854
- buffer = ""
896
+ buffer = ''
855
897
  buffer << @packed_indexes
856
898
  buffer << [ticket].pack(PACK_UINT16)
857
- buffer << exchange.to_s.bytesize.chr
858
- buffer << exchange.to_s
899
+ buffer << exchange.bytesize.chr
900
+ buffer << exchange
859
901
  bit_buffer = 0
860
902
  bit_buffer = bit_buffer | (1 << 0) if if_unused
861
903
  bit_buffer = bit_buffer | (1 << 1) if nowait
862
904
  buffer << [bit_buffer].pack(PACK_CHAR)
863
905
  MethodFrame.new(buffer, channel)
864
906
  end
907
+
865
908
  end
866
909
 
867
910
  class DeleteOk < Protocol::Method
@@ -882,6 +925,8 @@ module AMQ
882
925
  def self.has_content?
883
926
  false
884
927
  end
928
+
929
+
885
930
  end
886
931
 
887
932
  class Bind < Protocol::Method
@@ -890,29 +935,31 @@ module AMQ
890
935
  @index = 0x0028001E # 40, 30, 2621470
891
936
  @packed_indexes = [40, 30].pack(PACK_UINT16_X2).freeze
892
937
 
938
+
893
939
  def self.has_content?
894
940
  false
895
941
  end
896
942
 
897
943
  # @return
898
- # ["ticket = 0", "destination = nil", "source = nil", "routing_key = EMPTY_STRING", "nowait = false", "arguments = {}"]
944
+ # [u'ticket = 0', u'destination = nil', u'source = nil', u'routing_key = EMPTY_STRING', u'nowait = false', u'arguments = {}']
899
945
  def self.encode(channel, destination, source, routing_key, nowait, arguments)
900
946
  ticket = 0
901
- buffer = ""
947
+ buffer = ''
902
948
  buffer << @packed_indexes
903
949
  buffer << [ticket].pack(PACK_UINT16)
904
- buffer << destination.to_s.bytesize.chr
905
- buffer << destination.to_s
906
- buffer << source.to_s.bytesize.chr
907
- buffer << source.to_s
908
- buffer << routing_key.to_s.bytesize.chr
909
- buffer << routing_key.to_s
950
+ buffer << destination.bytesize.chr
951
+ buffer << destination
952
+ buffer << source.bytesize.chr
953
+ buffer << source
954
+ buffer << routing_key.bytesize.chr
955
+ buffer << routing_key
910
956
  bit_buffer = 0
911
957
  bit_buffer = bit_buffer | (1 << 0) if nowait
912
958
  buffer << [bit_buffer].pack(PACK_CHAR)
913
959
  buffer << AMQ::Protocol::Table.encode(arguments)
914
960
  MethodFrame.new(buffer, channel)
915
961
  end
962
+
916
963
  end
917
964
 
918
965
  class BindOk < Protocol::Method
@@ -933,6 +980,8 @@ module AMQ
933
980
  def self.has_content?
934
981
  false
935
982
  end
983
+
984
+
936
985
  end
937
986
 
938
987
  class Unbind < Protocol::Method
@@ -941,29 +990,31 @@ module AMQ
941
990
  @index = 0x00280028 # 40, 40, 2621480
942
991
  @packed_indexes = [40, 40].pack(PACK_UINT16_X2).freeze
943
992
 
993
+
944
994
  def self.has_content?
945
995
  false
946
996
  end
947
997
 
948
998
  # @return
949
- # ["ticket = 0", "destination = nil", "source = nil", "routing_key = EMPTY_STRING", "nowait = false", "arguments = {}"]
999
+ # [u'ticket = 0', u'destination = nil', u'source = nil', u'routing_key = EMPTY_STRING', u'nowait = false', u'arguments = {}']
950
1000
  def self.encode(channel, destination, source, routing_key, nowait, arguments)
951
1001
  ticket = 0
952
- buffer = ""
1002
+ buffer = ''
953
1003
  buffer << @packed_indexes
954
1004
  buffer << [ticket].pack(PACK_UINT16)
955
- buffer << destination.to_s.bytesize.chr
956
- buffer << destination.to_s
957
- buffer << source.to_s.bytesize.chr
958
- buffer << source.to_s
959
- buffer << routing_key.to_s.bytesize.chr
960
- buffer << routing_key.to_s
1005
+ buffer << destination.bytesize.chr
1006
+ buffer << destination
1007
+ buffer << source.bytesize.chr
1008
+ buffer << source
1009
+ buffer << routing_key.bytesize.chr
1010
+ buffer << routing_key
961
1011
  bit_buffer = 0
962
1012
  bit_buffer = bit_buffer | (1 << 0) if nowait
963
1013
  buffer << [bit_buffer].pack(PACK_CHAR)
964
1014
  buffer << AMQ::Protocol::Table.encode(arguments)
965
1015
  MethodFrame.new(buffer, channel)
966
1016
  end
1017
+
967
1018
  end
968
1019
 
969
1020
  class UnbindOk < Protocol::Method
@@ -984,32 +1035,38 @@ module AMQ
984
1035
  def self.has_content?
985
1036
  false
986
1037
  end
1038
+
1039
+
987
1040
  end
1041
+
988
1042
  end
989
1043
 
990
1044
  class Queue < Protocol::Class
991
1045
  @name = "queue"
992
1046
  @method_id = 50
993
1047
 
1048
+
1049
+
994
1050
  class Declare < Protocol::Method
995
1051
  @name = "queue.declare"
996
1052
  @method_id = 10
997
1053
  @index = 0x0032000A # 50, 10, 3276810
998
1054
  @packed_indexes = [50, 10].pack(PACK_UINT16_X2).freeze
999
1055
 
1056
+
1000
1057
  def self.has_content?
1001
1058
  false
1002
1059
  end
1003
1060
 
1004
1061
  # @return
1005
- # ["ticket = 0", "queue = EMPTY_STRING", "passive = false", "durable = false", "exclusive = false", "auto_delete = false", "nowait = false", "arguments = {}"]
1062
+ # [u'ticket = 0', u'queue = EMPTY_STRING', u'passive = false', u'durable = false', u'exclusive = false', u'auto_delete = false', u'nowait = false', u'arguments = {}']
1006
1063
  def self.encode(channel, queue, passive, durable, exclusive, auto_delete, nowait, arguments)
1007
1064
  ticket = 0
1008
- buffer = ""
1065
+ buffer = ''
1009
1066
  buffer << @packed_indexes
1010
1067
  buffer << [ticket].pack(PACK_UINT16)
1011
- buffer << queue.to_s.bytesize.chr
1012
- buffer << queue.to_s
1068
+ buffer << queue.bytesize.chr
1069
+ buffer << queue
1013
1070
  bit_buffer = 0
1014
1071
  bit_buffer = bit_buffer | (1 << 0) if passive
1015
1072
  bit_buffer = bit_buffer | (1 << 1) if durable
@@ -1020,6 +1077,7 @@ module AMQ
1020
1077
  buffer << AMQ::Protocol::Table.encode(arguments)
1021
1078
  MethodFrame.new(buffer, channel)
1022
1079
  end
1080
+
1023
1081
  end
1024
1082
 
1025
1083
  class DeclareOk < Protocol::Method
@@ -1052,6 +1110,8 @@ module AMQ
1052
1110
  def self.has_content?
1053
1111
  false
1054
1112
  end
1113
+
1114
+
1055
1115
  end
1056
1116
 
1057
1117
  class Bind < Protocol::Method
@@ -1060,29 +1120,31 @@ module AMQ
1060
1120
  @index = 0x00320014 # 50, 20, 3276820
1061
1121
  @packed_indexes = [50, 20].pack(PACK_UINT16_X2).freeze
1062
1122
 
1123
+
1063
1124
  def self.has_content?
1064
1125
  false
1065
1126
  end
1066
1127
 
1067
1128
  # @return
1068
- # ["ticket = 0", "queue = EMPTY_STRING", "exchange = nil", "routing_key = EMPTY_STRING", "nowait = false", "arguments = {}"]
1129
+ # [u'ticket = 0', u'queue = EMPTY_STRING', u'exchange = nil', u'routing_key = EMPTY_STRING', u'nowait = false', u'arguments = {}']
1069
1130
  def self.encode(channel, queue, exchange, routing_key, nowait, arguments)
1070
1131
  ticket = 0
1071
- buffer = ""
1132
+ buffer = ''
1072
1133
  buffer << @packed_indexes
1073
1134
  buffer << [ticket].pack(PACK_UINT16)
1074
- buffer << queue.to_s.bytesize.chr
1075
- buffer << queue.to_s
1076
- buffer << exchange.to_s.bytesize.chr
1077
- buffer << exchange.to_s
1078
- buffer << routing_key.to_s.bytesize.chr
1079
- buffer << routing_key.to_s
1135
+ buffer << queue.bytesize.chr
1136
+ buffer << queue
1137
+ buffer << exchange.bytesize.chr
1138
+ buffer << exchange
1139
+ buffer << routing_key.bytesize.chr
1140
+ buffer << routing_key
1080
1141
  bit_buffer = 0
1081
1142
  bit_buffer = bit_buffer | (1 << 0) if nowait
1082
1143
  buffer << [bit_buffer].pack(PACK_CHAR)
1083
1144
  buffer << AMQ::Protocol::Table.encode(arguments)
1084
1145
  MethodFrame.new(buffer, channel)
1085
1146
  end
1147
+
1086
1148
  end
1087
1149
 
1088
1150
  class BindOk < Protocol::Method
@@ -1103,6 +1165,8 @@ module AMQ
1103
1165
  def self.has_content?
1104
1166
  false
1105
1167
  end
1168
+
1169
+
1106
1170
  end
1107
1171
 
1108
1172
  class Purge < Protocol::Method
@@ -1111,24 +1175,26 @@ module AMQ
1111
1175
  @index = 0x0032001E # 50, 30, 3276830
1112
1176
  @packed_indexes = [50, 30].pack(PACK_UINT16_X2).freeze
1113
1177
 
1178
+
1114
1179
  def self.has_content?
1115
1180
  false
1116
1181
  end
1117
1182
 
1118
1183
  # @return
1119
- # ["ticket = 0", "queue = EMPTY_STRING", "nowait = false"]
1184
+ # [u'ticket = 0', u'queue = EMPTY_STRING', u'nowait = false']
1120
1185
  def self.encode(channel, queue, nowait)
1121
1186
  ticket = 0
1122
- buffer = ""
1187
+ buffer = ''
1123
1188
  buffer << @packed_indexes
1124
1189
  buffer << [ticket].pack(PACK_UINT16)
1125
- buffer << queue.to_s.bytesize.chr
1126
- buffer << queue.to_s
1190
+ buffer << queue.bytesize.chr
1191
+ buffer << queue
1127
1192
  bit_buffer = 0
1128
1193
  bit_buffer = bit_buffer | (1 << 0) if nowait
1129
1194
  buffer << [bit_buffer].pack(PACK_CHAR)
1130
1195
  MethodFrame.new(buffer, channel)
1131
1196
  end
1197
+
1132
1198
  end
1133
1199
 
1134
1200
  class PurgeOk < Protocol::Method
@@ -1153,6 +1219,8 @@ module AMQ
1153
1219
  def self.has_content?
1154
1220
  false
1155
1221
  end
1222
+
1223
+
1156
1224
  end
1157
1225
 
1158
1226
  class Delete < Protocol::Method
@@ -1161,19 +1229,20 @@ module AMQ
1161
1229
  @index = 0x00320028 # 50, 40, 3276840
1162
1230
  @packed_indexes = [50, 40].pack(PACK_UINT16_X2).freeze
1163
1231
 
1232
+
1164
1233
  def self.has_content?
1165
1234
  false
1166
1235
  end
1167
1236
 
1168
1237
  # @return
1169
- # ["ticket = 0", "queue = EMPTY_STRING", "if_unused = false", "if_empty = false", "nowait = false"]
1238
+ # [u'ticket = 0', u'queue = EMPTY_STRING', u'if_unused = false', u'if_empty = false', u'nowait = false']
1170
1239
  def self.encode(channel, queue, if_unused, if_empty, nowait)
1171
1240
  ticket = 0
1172
- buffer = ""
1241
+ buffer = ''
1173
1242
  buffer << @packed_indexes
1174
1243
  buffer << [ticket].pack(PACK_UINT16)
1175
- buffer << queue.to_s.bytesize.chr
1176
- buffer << queue.to_s
1244
+ buffer << queue.bytesize.chr
1245
+ buffer << queue
1177
1246
  bit_buffer = 0
1178
1247
  bit_buffer = bit_buffer | (1 << 0) if if_unused
1179
1248
  bit_buffer = bit_buffer | (1 << 1) if if_empty
@@ -1181,6 +1250,7 @@ module AMQ
1181
1250
  buffer << [bit_buffer].pack(PACK_CHAR)
1182
1251
  MethodFrame.new(buffer, channel)
1183
1252
  end
1253
+
1184
1254
  end
1185
1255
 
1186
1256
  class DeleteOk < Protocol::Method
@@ -1205,6 +1275,8 @@ module AMQ
1205
1275
  def self.has_content?
1206
1276
  false
1207
1277
  end
1278
+
1279
+
1208
1280
  end
1209
1281
 
1210
1282
  class Unbind < Protocol::Method
@@ -1213,26 +1285,28 @@ module AMQ
1213
1285
  @index = 0x00320032 # 50, 50, 3276850
1214
1286
  @packed_indexes = [50, 50].pack(PACK_UINT16_X2).freeze
1215
1287
 
1288
+
1216
1289
  def self.has_content?
1217
1290
  false
1218
1291
  end
1219
1292
 
1220
1293
  # @return
1221
- # ["ticket = 0", "queue = EMPTY_STRING", "exchange = nil", "routing_key = EMPTY_STRING", "arguments = {}"]
1294
+ # [u'ticket = 0', u'queue = EMPTY_STRING', u'exchange = nil', u'routing_key = EMPTY_STRING', u'arguments = {}']
1222
1295
  def self.encode(channel, queue, exchange, routing_key, arguments)
1223
1296
  ticket = 0
1224
- buffer = ""
1297
+ buffer = ''
1225
1298
  buffer << @packed_indexes
1226
1299
  buffer << [ticket].pack(PACK_UINT16)
1227
- buffer << queue.to_s.bytesize.chr
1228
- buffer << queue.to_s
1229
- buffer << exchange.to_s.bytesize.chr
1230
- buffer << exchange.to_s
1231
- buffer << routing_key.to_s.bytesize.chr
1232
- buffer << routing_key.to_s
1300
+ buffer << queue.bytesize.chr
1301
+ buffer << queue
1302
+ buffer << exchange.bytesize.chr
1303
+ buffer << exchange
1304
+ buffer << routing_key.bytesize.chr
1305
+ buffer << routing_key
1233
1306
  buffer << AMQ::Protocol::Table.encode(arguments)
1234
1307
  MethodFrame.new(buffer, channel)
1235
1308
  end
1309
+
1236
1310
  end
1237
1311
 
1238
1312
  class UnbindOk < Protocol::Method
@@ -1253,7 +1327,10 @@ module AMQ
1253
1327
  def self.has_content?
1254
1328
  false
1255
1329
  end
1330
+
1331
+
1256
1332
  end
1333
+
1257
1334
  end
1258
1335
 
1259
1336
  class Basic < Protocol::Class
@@ -1279,122 +1356,124 @@ module AMQ
1279
1356
 
1280
1357
  # 1 << 15
1281
1358
  def self.encode_content_type(value)
1282
- buffer = ""
1283
- buffer << value.to_s.bytesize.chr
1284
- buffer << value.to_s
1359
+ buffer = ''
1360
+ buffer << value.bytesize.chr
1361
+ buffer << value
1285
1362
  [0, 0x8000, buffer]
1286
1363
  end
1287
1364
 
1288
1365
  # 1 << 14
1289
1366
  def self.encode_content_encoding(value)
1290
- buffer = ""
1291
- buffer << value.to_s.bytesize.chr
1292
- buffer << value.to_s
1367
+ buffer = ''
1368
+ buffer << value.bytesize.chr
1369
+ buffer << value
1293
1370
  [1, 0x4000, buffer]
1294
1371
  end
1295
1372
 
1296
1373
  # 1 << 13
1297
1374
  def self.encode_headers(value)
1298
- buffer = ""
1375
+ buffer = ''
1299
1376
  buffer << AMQ::Protocol::Table.encode(value)
1300
1377
  [2, 0x2000, buffer]
1301
1378
  end
1302
1379
 
1303
1380
  # 1 << 12
1304
1381
  def self.encode_delivery_mode(value)
1305
- buffer = ""
1382
+ buffer = ''
1306
1383
  buffer << [value].pack(PACK_CHAR)
1307
1384
  [3, 0x1000, buffer]
1308
1385
  end
1309
1386
 
1310
1387
  # 1 << 11
1311
1388
  def self.encode_priority(value)
1312
- buffer = ""
1389
+ buffer = ''
1313
1390
  buffer << [value].pack(PACK_CHAR)
1314
1391
  [4, 0x0800, buffer]
1315
1392
  end
1316
1393
 
1317
1394
  # 1 << 10
1318
1395
  def self.encode_correlation_id(value)
1319
- buffer = ""
1320
- buffer << value.to_s.bytesize.chr
1321
- buffer << value.to_s
1396
+ buffer = ''
1397
+ buffer << value.bytesize.chr
1398
+ buffer << value
1322
1399
  [5, 0x0400, buffer]
1323
1400
  end
1324
1401
 
1325
1402
  # 1 << 9
1326
1403
  def self.encode_reply_to(value)
1327
- buffer = ""
1328
- buffer << value.to_s.bytesize.chr
1329
- buffer << value.to_s
1404
+ buffer = ''
1405
+ buffer << value.bytesize.chr
1406
+ buffer << value
1330
1407
  [6, 0x0200, buffer]
1331
1408
  end
1332
1409
 
1333
1410
  # 1 << 8
1334
1411
  def self.encode_expiration(value)
1335
- buffer = ""
1336
- buffer << value.to_s.bytesize.chr
1337
- buffer << value.to_s
1412
+ buffer = ''
1413
+ buffer << value.bytesize.chr
1414
+ buffer << value
1338
1415
  [7, 0x0100, buffer]
1339
1416
  end
1340
1417
 
1341
1418
  # 1 << 7
1342
1419
  def self.encode_message_id(value)
1343
- buffer = ""
1344
- buffer << value.to_s.bytesize.chr
1345
- buffer << value.to_s
1420
+ buffer = ''
1421
+ buffer << value.bytesize.chr
1422
+ buffer << value
1346
1423
  [8, 0x0080, buffer]
1347
1424
  end
1348
1425
 
1349
1426
  # 1 << 6
1350
1427
  def self.encode_timestamp(value)
1351
- buffer = ""
1428
+ buffer = ''
1352
1429
  buffer << AMQ::Hacks.pack_64_big_endian(value)
1353
1430
  [9, 0x0040, buffer]
1354
1431
  end
1355
1432
 
1356
1433
  # 1 << 5
1357
1434
  def self.encode_type(value)
1358
- buffer = ""
1359
- buffer << value.to_s.bytesize.chr
1360
- buffer << value.to_s
1435
+ buffer = ''
1436
+ buffer << value.bytesize.chr
1437
+ buffer << value
1361
1438
  [10, 0x0020, buffer]
1362
1439
  end
1363
1440
 
1364
1441
  # 1 << 4
1365
1442
  def self.encode_user_id(value)
1366
- buffer = ""
1367
- buffer << value.to_s.bytesize.chr
1368
- buffer << value.to_s
1443
+ buffer = ''
1444
+ buffer << value.bytesize.chr
1445
+ buffer << value
1369
1446
  [11, 0x0010, buffer]
1370
1447
  end
1371
1448
 
1372
1449
  # 1 << 3
1373
1450
  def self.encode_app_id(value)
1374
- buffer = ""
1375
- buffer << value.to_s.bytesize.chr
1376
- buffer << value.to_s
1451
+ buffer = ''
1452
+ buffer << value.bytesize.chr
1453
+ buffer << value
1377
1454
  [12, 0x0008, buffer]
1378
1455
  end
1379
1456
 
1380
1457
  # 1 << 2
1381
1458
  def self.encode_cluster_id(value)
1382
- buffer = ""
1383
- buffer << value.to_s.bytesize.chr
1384
- buffer << value.to_s
1459
+ buffer = ''
1460
+ buffer << value.bytesize.chr
1461
+ buffer << value
1385
1462
  [13, 0x0004, buffer]
1386
1463
  end
1387
1464
 
1465
+
1466
+
1388
1467
  def self.encode_properties(body_size, properties)
1389
1468
  pieces, flags = [], 0
1390
1469
 
1391
- properties.reject {|key, value| value.nil?}.each do |key, value|
1392
- i, f, result = self.__send__(:"encode_#{key}", value)
1470
+ properties.each do |key, value|
1471
+ i, f, result = self.send(:"encode_#{key}", value)
1393
1472
  flags |= f
1394
1473
  pieces[i] = result
1395
1474
  end
1396
1475
 
1397
- # result = [60, 0, body_size, flags].pack("n2Qn")
1476
+ # result = [60, 0, body_size, flags].pack('n2Qn')
1398
1477
  result = [60, 0].pack(PACK_UINT16_X2)
1399
1478
  result += AMQ::Hacks.pack_64_big_endian(body_size)
1400
1479
  result += [flags].pack(PACK_UINT16)
@@ -1436,7 +1515,7 @@ module AMQ
1436
1515
  0x0004 => :shortstr,
1437
1516
  }
1438
1517
 
1439
- # Hash doesn"t give any guarantees on keys order, we will do it in a
1518
+ # Hash doesn't give any guarantees on keys order, we will do it in a
1440
1519
  # straightforward way
1441
1520
  DECODE_PROPERTIES_KEYS = [
1442
1521
  0x8000,
@@ -1494,14 +1573,15 @@ module AMQ
1494
1573
  @index = 0x003C000A # 60, 10, 3932170
1495
1574
  @packed_indexes = [60, 10].pack(PACK_UINT16_X2).freeze
1496
1575
 
1576
+
1497
1577
  def self.has_content?
1498
1578
  false
1499
1579
  end
1500
1580
 
1501
1581
  # @return
1502
- # ["prefetch_size = false", "prefetch_count = false", "global = false"]
1582
+ # [u'prefetch_size = false', u'prefetch_count = false', u'global = false']
1503
1583
  def self.encode(channel, prefetch_size, prefetch_count, global)
1504
- buffer = ""
1584
+ buffer = ''
1505
1585
  buffer << @packed_indexes
1506
1586
  buffer << [prefetch_size].pack(PACK_UINT32)
1507
1587
  buffer << [prefetch_count].pack(PACK_UINT16)
@@ -1510,6 +1590,7 @@ module AMQ
1510
1590
  buffer << [bit_buffer].pack(PACK_CHAR)
1511
1591
  MethodFrame.new(buffer, channel)
1512
1592
  end
1593
+
1513
1594
  end
1514
1595
 
1515
1596
  class QosOk < Protocol::Method
@@ -1530,6 +1611,8 @@ module AMQ
1530
1611
  def self.has_content?
1531
1612
  false
1532
1613
  end
1614
+
1615
+
1533
1616
  end
1534
1617
 
1535
1618
  class Consume < Protocol::Method
@@ -1538,21 +1621,22 @@ module AMQ
1538
1621
  @index = 0x003C0014 # 60, 20, 3932180
1539
1622
  @packed_indexes = [60, 20].pack(PACK_UINT16_X2).freeze
1540
1623
 
1624
+
1541
1625
  def self.has_content?
1542
1626
  false
1543
1627
  end
1544
1628
 
1545
1629
  # @return
1546
- # ["ticket = 0", "queue = EMPTY_STRING", "consumer_tag = EMPTY_STRING", "no_local = false", "no_ack = false", "exclusive = false", "nowait = false", "arguments = {}"]
1630
+ # [u'ticket = 0', u'queue = EMPTY_STRING', u'consumer_tag = EMPTY_STRING', u'no_local = false', u'no_ack = false', u'exclusive = false', u'nowait = false', u'arguments = {}']
1547
1631
  def self.encode(channel, queue, consumer_tag, no_local, no_ack, exclusive, nowait, arguments)
1548
1632
  ticket = 0
1549
- buffer = ""
1633
+ buffer = ''
1550
1634
  buffer << @packed_indexes
1551
1635
  buffer << [ticket].pack(PACK_UINT16)
1552
- buffer << queue.to_s.bytesize.chr
1553
- buffer << queue.to_s
1554
- buffer << consumer_tag.to_s.bytesize.chr
1555
- buffer << consumer_tag.to_s
1636
+ buffer << queue.bytesize.chr
1637
+ buffer << queue
1638
+ buffer << consumer_tag.bytesize.chr
1639
+ buffer << consumer_tag
1556
1640
  bit_buffer = 0
1557
1641
  bit_buffer = bit_buffer | (1 << 0) if no_local
1558
1642
  bit_buffer = bit_buffer | (1 << 1) if no_ack
@@ -1562,6 +1646,7 @@ module AMQ
1562
1646
  buffer << AMQ::Protocol::Table.encode(arguments)
1563
1647
  MethodFrame.new(buffer, channel)
1564
1648
  end
1649
+
1565
1650
  end
1566
1651
 
1567
1652
  class ConsumeOk < Protocol::Method
@@ -1588,6 +1673,8 @@ module AMQ
1588
1673
  def self.has_content?
1589
1674
  false
1590
1675
  end
1676
+
1677
+
1591
1678
  end
1592
1679
 
1593
1680
  class Cancel < Protocol::Method
@@ -1596,41 +1683,24 @@ module AMQ
1596
1683
  @index = 0x003C001E # 60, 30, 3932190
1597
1684
  @packed_indexes = [60, 30].pack(PACK_UINT16_X2).freeze
1598
1685
 
1599
- # @return
1600
- def self.decode(data)
1601
- offset = 0
1602
- length = data[offset, 1].unpack(PACK_CHAR).first
1603
- offset += 1
1604
- consumer_tag = data[offset, length]
1605
- offset += length
1606
- bit_buffer = data[offset, 1].unpack(PACK_CHAR).first
1607
- offset += 1
1608
- nowait = (bit_buffer & (1 << 0)) != 0
1609
- self.new(consumer_tag, nowait)
1610
- end
1611
-
1612
- attr_reader :consumer_tag, :nowait
1613
- def initialize(consumer_tag, nowait)
1614
- @consumer_tag = consumer_tag
1615
- @nowait = nowait
1616
- end
1617
1686
 
1618
1687
  def self.has_content?
1619
1688
  false
1620
1689
  end
1621
1690
 
1622
1691
  # @return
1623
- # ["consumer_tag = nil", "nowait = false"]
1692
+ # [u'consumer_tag = nil', u'nowait = false']
1624
1693
  def self.encode(channel, consumer_tag, nowait)
1625
- buffer = ""
1694
+ buffer = ''
1626
1695
  buffer << @packed_indexes
1627
- buffer << consumer_tag.to_s.bytesize.chr
1628
- buffer << consumer_tag.to_s
1696
+ buffer << consumer_tag.bytesize.chr
1697
+ buffer << consumer_tag
1629
1698
  bit_buffer = 0
1630
1699
  bit_buffer = bit_buffer | (1 << 0) if nowait
1631
1700
  buffer << [bit_buffer].pack(PACK_CHAR)
1632
1701
  MethodFrame.new(buffer, channel)
1633
1702
  end
1703
+
1634
1704
  end
1635
1705
 
1636
1706
  class CancelOk < Protocol::Method
@@ -1657,6 +1727,8 @@ module AMQ
1657
1727
  def self.has_content?
1658
1728
  false
1659
1729
  end
1730
+
1731
+
1660
1732
  end
1661
1733
 
1662
1734
  class Publish < Protocol::Method
@@ -1665,21 +1737,22 @@ module AMQ
1665
1737
  @index = 0x003C0028 # 60, 40, 3932200
1666
1738
  @packed_indexes = [60, 40].pack(PACK_UINT16_X2).freeze
1667
1739
 
1740
+
1668
1741
  def self.has_content?
1669
1742
  true
1670
1743
  end
1671
1744
 
1672
1745
  # @return
1673
- # ["ticket = 0", "exchange = EMPTY_STRING", "routing_key = EMPTY_STRING", "mandatory = false", "immediate = false", "user_headers = nil", "payload = """, "frame_size = nil"]
1746
+ # [u'ticket = 0', u'exchange = EMPTY_STRING', u'routing_key = EMPTY_STRING', u'mandatory = false', u'immediate = false', 'user_headers = nil', 'payload = ""', 'frame_size = nil']
1674
1747
  def self.encode(channel, payload, user_headers, exchange, routing_key, mandatory, immediate, frame_size)
1675
1748
  ticket = 0
1676
- buffer = ""
1749
+ buffer = ''
1677
1750
  buffer << @packed_indexes
1678
1751
  buffer << [ticket].pack(PACK_UINT16)
1679
- buffer << exchange.to_s.bytesize.chr
1680
- buffer << exchange.to_s
1681
- buffer << routing_key.to_s.bytesize.chr
1682
- buffer << routing_key.to_s
1752
+ buffer << exchange.bytesize.chr
1753
+ buffer << exchange
1754
+ buffer << routing_key.bytesize.chr
1755
+ buffer << routing_key
1683
1756
  bit_buffer = 0
1684
1757
  bit_buffer = bit_buffer | (1 << 0) if mandatory
1685
1758
  bit_buffer = bit_buffer | (1 << 1) if immediate
@@ -1694,6 +1767,7 @@ module AMQ
1694
1767
  frames << HeaderFrame.new(properties_payload, channel)
1695
1768
  frames + self.encode_body(payload, channel, frame_size)
1696
1769
  end
1770
+
1697
1771
  end
1698
1772
 
1699
1773
  class Return < Protocol::Method
@@ -1733,6 +1807,8 @@ module AMQ
1733
1807
  def self.has_content?
1734
1808
  true
1735
1809
  end
1810
+
1811
+
1736
1812
  end
1737
1813
 
1738
1814
  class Deliver < Protocol::Method
@@ -1776,6 +1852,8 @@ module AMQ
1776
1852
  def self.has_content?
1777
1853
  true
1778
1854
  end
1855
+
1856
+
1779
1857
  end
1780
1858
 
1781
1859
  class Get < Protocol::Method
@@ -1784,24 +1862,26 @@ module AMQ
1784
1862
  @index = 0x003C0046 # 60, 70, 3932230
1785
1863
  @packed_indexes = [60, 70].pack(PACK_UINT16_X2).freeze
1786
1864
 
1865
+
1787
1866
  def self.has_content?
1788
1867
  false
1789
1868
  end
1790
1869
 
1791
1870
  # @return
1792
- # ["ticket = 0", "queue = EMPTY_STRING", "no_ack = false"]
1871
+ # [u'ticket = 0', u'queue = EMPTY_STRING', u'no_ack = false']
1793
1872
  def self.encode(channel, queue, no_ack)
1794
1873
  ticket = 0
1795
- buffer = ""
1874
+ buffer = ''
1796
1875
  buffer << @packed_indexes
1797
1876
  buffer << [ticket].pack(PACK_UINT16)
1798
- buffer << queue.to_s.bytesize.chr
1799
- buffer << queue.to_s
1877
+ buffer << queue.bytesize.chr
1878
+ buffer << queue
1800
1879
  bit_buffer = 0
1801
1880
  bit_buffer = bit_buffer | (1 << 0) if no_ack
1802
1881
  buffer << [bit_buffer].pack(PACK_CHAR)
1803
1882
  MethodFrame.new(buffer, channel)
1804
1883
  end
1884
+
1805
1885
  end
1806
1886
 
1807
1887
  class GetOk < Protocol::Method
@@ -1843,6 +1923,8 @@ module AMQ
1843
1923
  def self.has_content?
1844
1924
  true
1845
1925
  end
1926
+
1927
+
1846
1928
  end
1847
1929
 
1848
1930
  class GetEmpty < Protocol::Method
@@ -1869,6 +1951,8 @@ module AMQ
1869
1951
  def self.has_content?
1870
1952
  false
1871
1953
  end
1954
+
1955
+
1872
1956
  end
1873
1957
 
1874
1958
  class Ack < Protocol::Method
@@ -1899,9 +1983,9 @@ module AMQ
1899
1983
  end
1900
1984
 
1901
1985
  # @return
1902
- # ["delivery_tag = false", "multiple = false"]
1986
+ # [u'delivery_tag = false', u'multiple = false']
1903
1987
  def self.encode(channel, delivery_tag, multiple)
1904
- buffer = ""
1988
+ buffer = ''
1905
1989
  buffer << @packed_indexes
1906
1990
  buffer << AMQ::Hacks.pack_64_big_endian(delivery_tag)
1907
1991
  bit_buffer = 0
@@ -1909,6 +1993,7 @@ module AMQ
1909
1993
  buffer << [bit_buffer].pack(PACK_CHAR)
1910
1994
  MethodFrame.new(buffer, channel)
1911
1995
  end
1996
+
1912
1997
  end
1913
1998
 
1914
1999
  class Reject < Protocol::Method
@@ -1917,14 +2002,15 @@ module AMQ
1917
2002
  @index = 0x003C005A # 60, 90, 3932250
1918
2003
  @packed_indexes = [60, 90].pack(PACK_UINT16_X2).freeze
1919
2004
 
2005
+
1920
2006
  def self.has_content?
1921
2007
  false
1922
2008
  end
1923
2009
 
1924
2010
  # @return
1925
- # ["delivery_tag = nil", "requeue = true"]
2011
+ # [u'delivery_tag = nil', u'requeue = true']
1926
2012
  def self.encode(channel, delivery_tag, requeue)
1927
- buffer = ""
2013
+ buffer = ''
1928
2014
  buffer << @packed_indexes
1929
2015
  buffer << AMQ::Hacks.pack_64_big_endian(delivery_tag)
1930
2016
  bit_buffer = 0
@@ -1932,6 +2018,7 @@ module AMQ
1932
2018
  buffer << [bit_buffer].pack(PACK_CHAR)
1933
2019
  MethodFrame.new(buffer, channel)
1934
2020
  end
2021
+
1935
2022
  end
1936
2023
 
1937
2024
  class RecoverAsync < Protocol::Method
@@ -1940,20 +2027,22 @@ module AMQ
1940
2027
  @index = 0x003C0064 # 60, 100, 3932260
1941
2028
  @packed_indexes = [60, 100].pack(PACK_UINT16_X2).freeze
1942
2029
 
2030
+
1943
2031
  def self.has_content?
1944
2032
  false
1945
2033
  end
1946
2034
 
1947
2035
  # @return
1948
- # ["requeue = false"]
2036
+ # [u'requeue = false']
1949
2037
  def self.encode(channel, requeue)
1950
- buffer = ""
2038
+ buffer = ''
1951
2039
  buffer << @packed_indexes
1952
2040
  bit_buffer = 0
1953
2041
  bit_buffer = bit_buffer | (1 << 0) if requeue
1954
2042
  buffer << [bit_buffer].pack(PACK_CHAR)
1955
2043
  MethodFrame.new(buffer, channel)
1956
2044
  end
2045
+
1957
2046
  end
1958
2047
 
1959
2048
  class Recover < Protocol::Method
@@ -1962,20 +2051,22 @@ module AMQ
1962
2051
  @index = 0x003C006E # 60, 110, 3932270
1963
2052
  @packed_indexes = [60, 110].pack(PACK_UINT16_X2).freeze
1964
2053
 
2054
+
1965
2055
  def self.has_content?
1966
2056
  false
1967
2057
  end
1968
2058
 
1969
2059
  # @return
1970
- # ["requeue = false"]
2060
+ # [u'requeue = false']
1971
2061
  def self.encode(channel, requeue)
1972
- buffer = ""
2062
+ buffer = ''
1973
2063
  buffer << @packed_indexes
1974
2064
  bit_buffer = 0
1975
2065
  bit_buffer = bit_buffer | (1 << 0) if requeue
1976
2066
  buffer << [bit_buffer].pack(PACK_CHAR)
1977
2067
  MethodFrame.new(buffer, channel)
1978
2068
  end
2069
+
1979
2070
  end
1980
2071
 
1981
2072
  class RecoverOk < Protocol::Method
@@ -1996,6 +2087,8 @@ module AMQ
1996
2087
  def self.has_content?
1997
2088
  false
1998
2089
  end
2090
+
2091
+
1999
2092
  end
2000
2093
 
2001
2094
  class Nack < Protocol::Method
@@ -2028,9 +2121,9 @@ module AMQ
2028
2121
  end
2029
2122
 
2030
2123
  # @return
2031
- # ["delivery_tag = false", "multiple = false", "requeue = true"]
2124
+ # [u'delivery_tag = false', u'multiple = false', u'requeue = true']
2032
2125
  def self.encode(channel, delivery_tag, multiple, requeue)
2033
- buffer = ""
2126
+ buffer = ''
2034
2127
  buffer << @packed_indexes
2035
2128
  buffer << AMQ::Hacks.pack_64_big_endian(delivery_tag)
2036
2129
  bit_buffer = 0
@@ -2039,19 +2132,24 @@ module AMQ
2039
2132
  buffer << [bit_buffer].pack(PACK_CHAR)
2040
2133
  MethodFrame.new(buffer, channel)
2041
2134
  end
2135
+
2042
2136
  end
2137
+
2043
2138
  end
2044
2139
 
2045
2140
  class Tx < Protocol::Class
2046
2141
  @name = "tx"
2047
2142
  @method_id = 90
2048
2143
 
2144
+
2145
+
2049
2146
  class Select < Protocol::Method
2050
2147
  @name = "tx.select"
2051
2148
  @method_id = 10
2052
2149
  @index = 0x005A000A # 90, 10, 5898250
2053
2150
  @packed_indexes = [90, 10].pack(PACK_UINT16_X2).freeze
2054
2151
 
2152
+
2055
2153
  def self.has_content?
2056
2154
  false
2057
2155
  end
@@ -2059,10 +2157,11 @@ module AMQ
2059
2157
  # @return
2060
2158
  # []
2061
2159
  def self.encode(channel)
2062
- buffer = ""
2160
+ buffer = ''
2063
2161
  buffer << @packed_indexes
2064
2162
  MethodFrame.new(buffer, channel)
2065
2163
  end
2164
+
2066
2165
  end
2067
2166
 
2068
2167
  class SelectOk < Protocol::Method
@@ -2083,6 +2182,8 @@ module AMQ
2083
2182
  def self.has_content?
2084
2183
  false
2085
2184
  end
2185
+
2186
+
2086
2187
  end
2087
2188
 
2088
2189
  class Commit < Protocol::Method
@@ -2091,6 +2192,7 @@ module AMQ
2091
2192
  @index = 0x005A0014 # 90, 20, 5898260
2092
2193
  @packed_indexes = [90, 20].pack(PACK_UINT16_X2).freeze
2093
2194
 
2195
+
2094
2196
  def self.has_content?
2095
2197
  false
2096
2198
  end
@@ -2098,10 +2200,11 @@ module AMQ
2098
2200
  # @return
2099
2201
  # []
2100
2202
  def self.encode(channel)
2101
- buffer = ""
2203
+ buffer = ''
2102
2204
  buffer << @packed_indexes
2103
2205
  MethodFrame.new(buffer, channel)
2104
2206
  end
2207
+
2105
2208
  end
2106
2209
 
2107
2210
  class CommitOk < Protocol::Method
@@ -2122,6 +2225,8 @@ module AMQ
2122
2225
  def self.has_content?
2123
2226
  false
2124
2227
  end
2228
+
2229
+
2125
2230
  end
2126
2231
 
2127
2232
  class Rollback < Protocol::Method
@@ -2130,6 +2235,7 @@ module AMQ
2130
2235
  @index = 0x005A001E # 90, 30, 5898270
2131
2236
  @packed_indexes = [90, 30].pack(PACK_UINT16_X2).freeze
2132
2237
 
2238
+
2133
2239
  def self.has_content?
2134
2240
  false
2135
2241
  end
@@ -2137,10 +2243,11 @@ module AMQ
2137
2243
  # @return
2138
2244
  # []
2139
2245
  def self.encode(channel)
2140
- buffer = ""
2246
+ buffer = ''
2141
2247
  buffer << @packed_indexes
2142
2248
  MethodFrame.new(buffer, channel)
2143
2249
  end
2250
+
2144
2251
  end
2145
2252
 
2146
2253
  class RollbackOk < Protocol::Method
@@ -2161,13 +2268,18 @@ module AMQ
2161
2268
  def self.has_content?
2162
2269
  false
2163
2270
  end
2271
+
2272
+
2164
2273
  end
2274
+
2165
2275
  end
2166
2276
 
2167
2277
  class Confirm < Protocol::Class
2168
2278
  @name = "confirm"
2169
2279
  @method_id = 85
2170
2280
 
2281
+
2282
+
2171
2283
  class Select < Protocol::Method
2172
2284
  @name = "confirm.select"
2173
2285
  @method_id = 10
@@ -2193,15 +2305,16 @@ module AMQ
2193
2305
  end
2194
2306
 
2195
2307
  # @return
2196
- # ["nowait = false"]
2308
+ # [u'nowait = false']
2197
2309
  def self.encode(channel, nowait)
2198
- buffer = ""
2310
+ buffer = ''
2199
2311
  buffer << @packed_indexes
2200
2312
  bit_buffer = 0
2201
2313
  bit_buffer = bit_buffer | (1 << 0) if nowait
2202
2314
  buffer << [bit_buffer].pack(PACK_CHAR)
2203
2315
  MethodFrame.new(buffer, channel)
2204
2316
  end
2317
+
2205
2318
  end
2206
2319
 
2207
2320
  class SelectOk < Protocol::Method
@@ -2226,13 +2339,16 @@ module AMQ
2226
2339
  # @return
2227
2340
  # []
2228
2341
  def self.encode(channel)
2229
- buffer = ""
2342
+ buffer = ''
2230
2343
  buffer << @packed_indexes
2231
2344
  MethodFrame.new(buffer, channel)
2232
2345
  end
2346
+
2233
2347
  end
2348
+
2234
2349
  end
2235
2350
 
2351
+
2236
2352
  METHODS = begin
2237
2353
  Method.methods.inject(Hash.new) do |hash, klass|
2238
2354
  hash.merge!(klass.index => klass)
@@ -2240,3 +2356,4 @@ module AMQ
2240
2356
  end
2241
2357
  end
2242
2358
  end
2359
+