amq-protocol 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +2 -1
- data/codegen/protocol.rb.pytemplate +9 -1
- data/lib/amq/protocol/client.rb +15 -3
- data/lib/amq/protocol/table.rb +4 -2
- data/lib/amq/protocol/table_value_decoder.rb +18 -5
- data/lib/amq/protocol/type_constants.rb +1 -1
- data/lib/amq/protocol/version.rb +1 -1
- data/spec/amq/protocol/table_spec.rb +8 -1
- metadata +90 -89
data/.gitignore
CHANGED
@@ -188,9 +188,17 @@ module AMQ
|
|
188
188
|
def self.encode_body(body, channel, frame_size)
|
189
189
|
return [] if body.empty?
|
190
190
|
|
191
|
-
#
|
191
|
+
# 8 = 1 + 2 + 4 + 1
|
192
|
+
# 1 byte of frame type
|
193
|
+
# 2 bytes of channel number
|
194
|
+
# 4 bytes of frame payload length
|
195
|
+
# 1 byte of payload trailer FRAME_END byte
|
192
196
|
limit = frame_size - 8
|
193
197
|
|
198
|
+
# Otherwise String#slice on 1.9 will operate with code points,
|
199
|
+
# and we need bytes. MK.
|
200
|
+
body.force_encoding("ASCII-8BIT") if RUBY_VERSION.to_f >= 1.9
|
201
|
+
|
194
202
|
array = Array.new
|
195
203
|
while body
|
196
204
|
payload, body = body[0, limit], body[limit, body.length - limit]
|
data/lib/amq/protocol/client.rb
CHANGED
@@ -31,6 +31,9 @@ module AMQ
|
|
31
31
|
PACK_32BIT_FLOAT = 'f'.freeze
|
32
32
|
PACK_64BIT_FLOAT = 'd'.freeze
|
33
33
|
|
34
|
+
PACK_SIGNED_8BIT = 'c'.freeze
|
35
|
+
PACK_SIGNED_16BIT = 's'.freeze
|
36
|
+
|
34
37
|
|
35
38
|
|
36
39
|
# @return [Array] Collection of subclasses of AMQ::Protocol::Class.
|
@@ -251,13 +254,20 @@ module AMQ
|
|
251
254
|
def self.encode_body(body, channel, frame_size)
|
252
255
|
return [] if body.empty?
|
253
256
|
|
254
|
-
#
|
257
|
+
# 8 = 1 + 2 + 4 + 1
|
258
|
+
# 1 byte of frame type
|
259
|
+
# 2 bytes of channel number
|
260
|
+
# 4 bytes of frame payload length
|
261
|
+
# 1 byte of payload trailer FRAME_END byte
|
255
262
|
limit = frame_size - 8
|
256
263
|
|
264
|
+
# Otherwise String#slice on 1.9 will operate with code points,
|
265
|
+
# and we need bytes. MK.
|
266
|
+
body.force_encoding("ASCII-8BIT") if RUBY_VERSION.to_f >= 1.9
|
267
|
+
|
257
268
|
array = Array.new
|
258
269
|
while body
|
259
270
|
payload, body = body[0, limit], body[limit, body.length - limit]
|
260
|
-
# array << [0x03, payload]
|
261
271
|
array << BodyFrame.new(payload, channel)
|
262
272
|
end
|
263
273
|
|
@@ -1785,7 +1795,9 @@ module AMQ
|
|
1785
1795
|
end
|
1786
1796
|
properties_payload = Basic.encode_properties(payload.bytesize, properties)
|
1787
1797
|
frames << HeaderFrame.new(properties_payload, channel)
|
1788
|
-
frames
|
1798
|
+
frames += self.encode_body(payload, channel, frame_size)
|
1799
|
+
|
1800
|
+
frames
|
1789
1801
|
end
|
1790
1802
|
|
1791
1803
|
end
|
data/lib/amq/protocol/table.rb
CHANGED
@@ -85,9 +85,11 @@ module AMQ
|
|
85
85
|
v, offset = TableValueDecoder.decode_boolean(data, offset)
|
86
86
|
v
|
87
87
|
when TYPE_SIGNED_8BIT then
|
88
|
-
|
88
|
+
v, offset = TableValueDecoder.decode_short_short(data, offset)
|
89
|
+
v
|
89
90
|
when TYPE_SIGNED_16BIT then
|
90
|
-
|
91
|
+
v, offset = TableValueDecoder.decode_short(data, offset)
|
92
|
+
v
|
91
93
|
when TYPE_SIGNED_64BIT then
|
92
94
|
v, offset = TableValueDecoder.decode_long(data, offset)
|
93
95
|
v
|
@@ -21,7 +21,7 @@ module AMQ
|
|
21
21
|
#
|
22
22
|
|
23
23
|
BIG_ENDIAN = ([1].pack("s") == "\x00\x01")
|
24
|
-
Q = "
|
24
|
+
Q = "q".freeze
|
25
25
|
|
26
26
|
|
27
27
|
def self.decode_array(data, initial_offset)
|
@@ -53,11 +53,11 @@ module AMQ
|
|
53
53
|
v, offset = decode_boolean(data, offset)
|
54
54
|
v
|
55
55
|
when TYPE_SIGNED_8BIT then
|
56
|
-
|
57
|
-
|
56
|
+
v, offset = decode_short_short(data, offset)
|
57
|
+
v
|
58
58
|
when TYPE_SIGNED_16BIT then
|
59
|
-
|
60
|
-
|
59
|
+
v, offset = decode_short(data, offset)
|
60
|
+
v
|
61
61
|
when TYPE_SIGNED_64BIT then
|
62
62
|
v, offset = decode_long(data, offset)
|
63
63
|
v
|
@@ -174,6 +174,19 @@ module AMQ
|
|
174
174
|
|
175
175
|
[v, offset]
|
176
176
|
end # self.decode_hash(data, offset)
|
177
|
+
|
178
|
+
|
179
|
+
def self.decode_short_short(data, offset)
|
180
|
+
v = data.slice(offset, 1).unpack(PACK_SIGNED_8BIT).first
|
181
|
+
offset += 1
|
182
|
+
[v, offset]
|
183
|
+
end
|
184
|
+
|
185
|
+
def self.decode_short(data, offset)
|
186
|
+
v = data.slice(offset, 2).unpack(PACK_SIGNED_16BIT).first
|
187
|
+
offset += 2
|
188
|
+
[v, offset]
|
189
|
+
end
|
177
190
|
end # TableValueDecoder
|
178
191
|
end # Protocol
|
179
192
|
end # AMQ
|
data/lib/amq/protocol/version.rb
CHANGED
@@ -171,8 +171,15 @@ module AMQ
|
|
171
171
|
Table.decode(Table.encode(input)).should == input
|
172
172
|
end
|
173
173
|
|
174
|
+
it 'is capable of decoding 8bit signed integers' do
|
175
|
+
output = TableValueDecoder.decode_short_short("\xC0",0).first
|
176
|
+
output.should == -64
|
177
|
+
end
|
174
178
|
|
175
|
-
|
179
|
+
it 'is capable of decoding 16bit signed integers' do
|
180
|
+
output = TableValueDecoder.decode_short("\b\xC0",0).first
|
181
|
+
output.should == -16376
|
182
|
+
end
|
176
183
|
|
177
184
|
it "is capable of decoding tables" do
|
178
185
|
input = {
|
metadata
CHANGED
@@ -1,106 +1,107 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: amq-protocol
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 1.2.0
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
8
|
-
- Jakub Stastny
|
9
|
-
- Michael S. Klishin
|
10
|
-
- Theo Hultberg
|
11
|
-
- Mark Abramov
|
12
|
-
autorequire:
|
7
|
+
authors:
|
8
|
+
- Jakub Stastny
|
9
|
+
- Michael S. Klishin
|
10
|
+
- Theo Hultberg
|
11
|
+
- Mark Abramov
|
12
|
+
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
|
15
|
+
|
16
|
+
date: 2013-02-12 00:00:00 Z
|
16
17
|
dependencies: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
-
|
22
|
-
bWljaGFlbEBub3ZlbWJlcmFpbi5jb20=
|
23
|
-
- !binary |-
|
24
|
-
c3Rhc3RueUAxMDFpZGVhcy5jeg==
|
18
|
+
|
19
|
+
description: " amq-protocol is an AMQP 0.9.1 serialization library for Ruby. It is not an\n AMQP client: amq-protocol only handles serialization and deserialization.\n If you want to write your own AMQP client, this gem can help you with that.\n"
|
20
|
+
email:
|
21
|
+
- michael@novemberain.com
|
22
|
+
- stastny@101ideas.cz
|
25
23
|
executables: []
|
24
|
+
|
26
25
|
extensions: []
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
- .
|
32
|
-
- .
|
33
|
-
- .
|
34
|
-
-
|
35
|
-
-
|
36
|
-
-
|
37
|
-
-
|
38
|
-
-
|
39
|
-
-
|
40
|
-
-
|
41
|
-
- codegen/
|
42
|
-
- codegen/
|
43
|
-
- codegen/
|
44
|
-
- codegen/
|
45
|
-
-
|
46
|
-
-
|
47
|
-
- lib/amq/
|
48
|
-
- lib/amq/
|
49
|
-
- lib/amq/
|
50
|
-
- lib/amq/protocol
|
51
|
-
- lib/amq/protocol/
|
52
|
-
- lib/amq/protocol/
|
53
|
-
- lib/amq/protocol/
|
54
|
-
- lib/amq/protocol/
|
55
|
-
- lib/amq/protocol/
|
56
|
-
- lib/amq/protocol/
|
57
|
-
- lib/amq/
|
58
|
-
-
|
59
|
-
- spec/amq/
|
60
|
-
- spec/amq/
|
61
|
-
- spec/amq/
|
62
|
-
- spec/amq/protocol/
|
63
|
-
- spec/amq/protocol/
|
64
|
-
- spec/amq/protocol/
|
65
|
-
- spec/amq/protocol/
|
66
|
-
- spec/amq/protocol/
|
67
|
-
- spec/amq/protocol/
|
68
|
-
- spec/amq/protocol/
|
69
|
-
- spec/amq/protocol/
|
70
|
-
- spec/amq/protocol/
|
71
|
-
- spec/amq/protocol/
|
72
|
-
- spec/amq/protocol/
|
73
|
-
- spec/amq/protocol/
|
74
|
-
- spec/amq/protocol/
|
75
|
-
- spec/amq/
|
76
|
-
- spec/amq/
|
77
|
-
- spec/
|
26
|
+
|
27
|
+
extra_rdoc_files:
|
28
|
+
- README.md
|
29
|
+
files:
|
30
|
+
- .gitignore
|
31
|
+
- .gitmodules
|
32
|
+
- .rspec
|
33
|
+
- .travis.yml
|
34
|
+
- ChangeLog.md
|
35
|
+
- Gemfile
|
36
|
+
- LICENSE
|
37
|
+
- PROFILING.md
|
38
|
+
- README.md
|
39
|
+
- amq-protocol.gemspec
|
40
|
+
- codegen/__init__.py
|
41
|
+
- codegen/amqp_0.9.1_changes.json
|
42
|
+
- codegen/codegen.py
|
43
|
+
- codegen/codegen_helpers.py
|
44
|
+
- codegen/protocol.rb.pytemplate
|
45
|
+
- generate.rb
|
46
|
+
- lib/amq/bit_set.rb
|
47
|
+
- lib/amq/hacks.rb
|
48
|
+
- lib/amq/int_allocator.rb
|
49
|
+
- lib/amq/protocol.rb
|
50
|
+
- lib/amq/protocol/client.rb
|
51
|
+
- lib/amq/protocol/frame.rb
|
52
|
+
- lib/amq/protocol/table.rb
|
53
|
+
- lib/amq/protocol/table_value_decoder.rb
|
54
|
+
- lib/amq/protocol/table_value_encoder.rb
|
55
|
+
- lib/amq/protocol/type_constants.rb
|
56
|
+
- lib/amq/protocol/version.rb
|
57
|
+
- lib/amq/settings.rb
|
58
|
+
- spec/amq/bit_set_spec.rb
|
59
|
+
- spec/amq/hacks_spec.rb
|
60
|
+
- spec/amq/int_allocator_spec.rb
|
61
|
+
- spec/amq/protocol/basic_spec.rb
|
62
|
+
- spec/amq/protocol/blank_body_encoding_spec.rb
|
63
|
+
- spec/amq/protocol/channel_spec.rb
|
64
|
+
- spec/amq/protocol/confirm_spec.rb
|
65
|
+
- spec/amq/protocol/connection_spec.rb
|
66
|
+
- spec/amq/protocol/constants_spec.rb
|
67
|
+
- spec/amq/protocol/exchange_spec.rb
|
68
|
+
- spec/amq/protocol/frame_spec.rb
|
69
|
+
- spec/amq/protocol/method_spec.rb
|
70
|
+
- spec/amq/protocol/queue_spec.rb
|
71
|
+
- spec/amq/protocol/table_spec.rb
|
72
|
+
- spec/amq/protocol/tx_spec.rb
|
73
|
+
- spec/amq/protocol/value_decoder_spec.rb
|
74
|
+
- spec/amq/protocol/value_encoder_spec.rb
|
75
|
+
- spec/amq/protocol_spec.rb
|
76
|
+
- spec/amq/settings_spec.rb
|
77
|
+
- spec/spec_helper.rb
|
78
78
|
homepage: http://github.com/ruby-amqp/amq-protocol
|
79
|
-
licenses:
|
80
|
-
- MIT
|
81
|
-
post_install_message:
|
79
|
+
licenses:
|
80
|
+
- MIT
|
81
|
+
post_install_message:
|
82
82
|
rdoc_options: []
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
- - ! '>='
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: !binary |-
|
90
|
-
MA==
|
83
|
+
|
84
|
+
require_paths:
|
85
|
+
- lib
|
86
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
91
87
|
none: false
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
MA==
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: "0"
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
93
|
none: false
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: "0"
|
99
98
|
requirements: []
|
99
|
+
|
100
100
|
rubyforge_project: amq-protocol
|
101
101
|
rubygems_version: 1.8.24
|
102
|
-
signing_key:
|
102
|
+
signing_key:
|
103
103
|
specification_version: 3
|
104
104
|
summary: AMQP 0.9.1 encoder & decoder.
|
105
105
|
test_files: []
|
106
|
-
|
106
|
+
|
107
|
+
has_rdoc:
|