amq-protocol 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog.md +5 -3
- data/lib/amq/protocol/frame.rb +27 -4
- data/lib/amq/protocol/version.rb +1 -1
- metadata +3 -2
data/ChangeLog.md
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
-
## Changes between 1.0.0 and 1.0
|
1
|
+
## Changes between 1.0.0 and 1.1.0
|
2
2
|
|
3
|
-
###
|
3
|
+
### Performance Enhancements
|
4
4
|
|
5
|
-
|
5
|
+
Encoding of large payloads is now done more efficiently.
|
6
|
+
|
7
|
+
Contributed by Greg Brockman.
|
6
8
|
|
7
9
|
|
8
10
|
## Changes between 1.0.0.pre6 and 1.0.0.pre7
|
data/lib/amq/protocol/frame.rb
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
module AMQ
|
4
4
|
module Protocol
|
5
|
-
SIMPLE_BYTE_PACK = 'c*'
|
6
5
|
class Frame
|
7
6
|
TYPES = {:method => 1, :headers => 2, :body => 3, :heartbeat => 8}.freeze
|
8
7
|
TYPES_REVERSE = TYPES.invert.freeze
|
@@ -10,11 +9,27 @@ module AMQ
|
|
10
9
|
CHANNEL_RANGE = (0..65535).freeze
|
11
10
|
FINAL_OCTET = "\xCE".freeze # 206
|
12
11
|
|
12
|
+
def self.encoded_payload(payload)
|
13
|
+
if payload.respond_to?(:force_encoding) && payload.encoding.name != 'BINARY'
|
14
|
+
# Only copy if we have to.
|
15
|
+
payload = payload.dup.force_encoding('BINARY')
|
16
|
+
end
|
17
|
+
payload
|
18
|
+
end
|
19
|
+
|
13
20
|
# The channel number is 0 for all frames which are global to the connection and 1-65535 for frames that refer to specific channels.
|
14
|
-
def self.
|
21
|
+
def self.encode_to_array(type, payload, channel)
|
15
22
|
raise RuntimeError.new("Channel has to be 0 or an integer in range 1..65535 but was #{channel.inspect}") unless CHANNEL_RANGE.include?(channel)
|
16
23
|
raise RuntimeError.new("Payload can't be nil") if payload.nil?
|
17
|
-
|
24
|
+
components = []
|
25
|
+
components << [find_type(type), channel, payload.bytesize].pack(PACK_CHAR_UINT16_UINT32)
|
26
|
+
components << encoded_payload(payload)
|
27
|
+
components << FINAL_OCTET
|
28
|
+
components
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.encode(type, payload, channel)
|
32
|
+
encode_to_array(type, payload, channel).join
|
18
33
|
end
|
19
34
|
|
20
35
|
class << self
|
@@ -80,8 +95,16 @@ This functionality is part of the https://github.com/ruby-amqp/amq-client librar
|
|
80
95
|
@payload.bytesize
|
81
96
|
end
|
82
97
|
|
98
|
+
def encode_to_array
|
99
|
+
components = []
|
100
|
+
components << [self.class.id, @channel, self.size].pack(PACK_CHAR_UINT16_UINT32)
|
101
|
+
components << self.class.encoded_payload(@payload)
|
102
|
+
components << FINAL_OCTET
|
103
|
+
components
|
104
|
+
end
|
105
|
+
|
83
106
|
def encode
|
84
|
-
|
107
|
+
encode_to_array.join
|
85
108
|
end
|
86
109
|
end
|
87
110
|
|
data/lib/amq/protocol/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: amq-protocol
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date:
|
15
|
+
date: 2013-01-21 00:00:00.000000000 Z
|
16
16
|
dependencies: []
|
17
17
|
description: ! " amq-protocol is an AMQP 0.9.1 serialization library for Ruby. It\
|
18
18
|
\ is not an\n AMQP client: amq-protocol only handles serialization and deserialization.\n\
|
@@ -103,3 +103,4 @@ signing_key:
|
|
103
103
|
specification_version: 3
|
104
104
|
summary: AMQP 0.9.1 encoder & decoder.
|
105
105
|
test_files: []
|
106
|
+
has_rdoc:
|