amq-protocol 2.4.0 → 2.5.1
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.
- checksums.yaml +4 -4
- data/ChangeLog.md +12 -5
- data/lib/amq/protocol/client.rb +30 -37
- data/lib/amq/protocol/frame.rb +2 -0
- data/lib/amq/protocol/version.rb +1 -1
- metadata +3 -52
- data/.github/ISSUE_TEMPLATE.md +0 -18
- data/.github/workflows/ci.yml +0 -31
- data/.gitignore +0 -18
- data/.gitmodules +0 -3
- data/.rspec +0 -1
- data/.travis.yml +0 -17
- data/Gemfile +0 -27
- data/Rakefile +0 -55
- data/amq-protocol.gemspec +0 -27
- data/benchmarks/frame_encoding.rb +0 -75
- data/benchmarks/int_allocator.rb +0 -34
- data/benchmarks/method_encoding.rb +0 -198
- data/benchmarks/pack_unpack.rb +0 -158
- data/benchmarks/pure/body_framing_with_256k_payload.rb +0 -28
- data/benchmarks/pure/body_framing_with_2k_payload.rb +0 -28
- data/benchmarks/run_all.rb +0 -64
- data/benchmarks/table_encoding.rb +0 -110
- data/codegen/__init__.py +0 -0
- data/codegen/amqp_0.9.1_changes.json +0 -1
- data/codegen/codegen.py +0 -151
- data/codegen/codegen_helpers.py +0 -162
- data/codegen/protocol.rb.pytemplate +0 -320
- data/generate.rb +0 -24
- data/profiling/README.md +0 -9
- data/profiling/stackprof/body_framing_with_2k_payload.rb +0 -33
- data/spec/amq/bit_set_spec.rb +0 -249
- data/spec/amq/endianness_spec.rb +0 -23
- data/spec/amq/int_allocator_spec.rb +0 -136
- data/spec/amq/pack_spec.rb +0 -58
- data/spec/amq/protocol/basic_spec.rb +0 -325
- data/spec/amq/protocol/blank_body_encoding_spec.rb +0 -9
- data/spec/amq/protocol/channel_spec.rb +0 -127
- data/spec/amq/protocol/confirm_spec.rb +0 -41
- data/spec/amq/protocol/connection_spec.rb +0 -146
- data/spec/amq/protocol/constants_spec.rb +0 -10
- data/spec/amq/protocol/exceptions_spec.rb +0 -70
- data/spec/amq/protocol/exchange_spec.rb +0 -106
- data/spec/amq/protocol/float_32bit_spec.rb +0 -27
- data/spec/amq/protocol/frame_spec.rb +0 -156
- data/spec/amq/protocol/method_spec.rb +0 -43
- data/spec/amq/protocol/queue_spec.rb +0 -126
- data/spec/amq/protocol/table_spec.rb +0 -291
- data/spec/amq/protocol/tx_spec.rb +0 -55
- data/spec/amq/protocol/value_decoder_spec.rb +0 -183
- data/spec/amq/protocol/value_encoder_spec.rb +0 -161
- data/spec/amq/protocol_spec.rb +0 -812
- data/spec/amq/settings_spec.rb +0 -58
- data/spec/amq/uri_parsing_spec.rb +0 -287
- data/spec/spec_helper.rb +0 -29
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7bd349803818e5eee9dbba49cdf59fad9666e8e7ed95229ed1bc7e7a4380fde5
|
|
4
|
+
data.tar.gz: b52bae3819d6fae2b2c6db5e1626ef6b98de74b0d24532b12f9a88ac75278ceb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9a138a490585effe6886c7b16f4bb4c0a9d7f878358bca45ee437ae714ebcef4375b9f684651e593906db4d61dabd9468290ee3b75f1ca2810f8855f82e6942c
|
|
7
|
+
data.tar.gz: 7f64f831d2cdca5885ab08967c3700519acf90c327307e79bac757a58b56d3a02acc3bbd41731a456b52f9b92f0678a1d5c7d0c68eff94febb09bc0b45239ded
|
data/ChangeLog.md
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
## Changes between 2.
|
|
1
|
+
## Changes between 2.5.0 and 2.5.1 (Jan 1, 2026)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
### Windows Installation Fixes
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
`2.4.0` and `2.5.0` versions unintentionally included files that were
|
|
6
|
+
symlinks, which caused installation on Windows to fail.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## Changes between 2.4.0 and 2.5.0 (Dec 31, 2025)
|
|
6
10
|
|
|
7
|
-
###
|
|
11
|
+
### Additional Consumer Hot Path Optimizations
|
|
8
12
|
|
|
9
|
-
|
|
13
|
+
A few more decode method optimizations for consumer delivery code paths.
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
## Changes between 2.3.4 and 2.4.0 (Dec 30, 2025)
|
|
10
17
|
|
|
11
18
|
### Performance Improvements
|
|
12
19
|
|
data/lib/amq/protocol/client.rb
CHANGED
|
@@ -1569,30 +1569,31 @@ module AMQ
|
|
|
1569
1569
|
0x0004,
|
|
1570
1570
|
]
|
|
1571
1571
|
|
|
1572
|
+
# Optimized decode_properties using getbyte and unpack1
|
|
1572
1573
|
def self.decode_properties(data)
|
|
1573
1574
|
offset, data_length, properties = 0, data.bytesize, {}
|
|
1574
1575
|
|
|
1575
|
-
compressed_index = data
|
|
1576
|
+
compressed_index = data.byteslice(offset, 2).unpack1(PACK_UINT16)
|
|
1576
1577
|
offset += 2
|
|
1577
1578
|
while data_length > offset
|
|
1578
1579
|
DECODE_PROPERTIES_KEYS.each do |key|
|
|
1579
1580
|
next unless compressed_index >= key
|
|
1580
1581
|
compressed_index -= key
|
|
1581
|
-
name = DECODE_PROPERTIES[key] || raise(RuntimeError.new("No property found for index #{
|
|
1582
|
+
name = DECODE_PROPERTIES[key] || raise(RuntimeError.new("No property found for index #{key.inspect}!"))
|
|
1582
1583
|
case DECODE_PROPERTIES_TYPE[key]
|
|
1583
1584
|
when :shortstr
|
|
1584
|
-
size = data
|
|
1585
|
+
size = data.getbyte(offset)
|
|
1585
1586
|
offset += 1
|
|
1586
|
-
result = data
|
|
1587
|
+
result = data.byteslice(offset, size)
|
|
1587
1588
|
when :octet
|
|
1588
1589
|
size = 1
|
|
1589
|
-
result = data
|
|
1590
|
+
result = data.getbyte(offset)
|
|
1590
1591
|
when :timestamp
|
|
1591
1592
|
size = 8
|
|
1592
|
-
result = Time.at(data
|
|
1593
|
+
result = Time.at(data.byteslice(offset, 8).unpack1(PACK_UINT64_BE))
|
|
1593
1594
|
when :table
|
|
1594
|
-
size = 4 + data
|
|
1595
|
-
result = Table.decode(data
|
|
1595
|
+
size = 4 + data.byteslice(offset, 4).unpack1(PACK_UINT32)
|
|
1596
|
+
result = Table.decode(data.byteslice(offset, size))
|
|
1596
1597
|
end
|
|
1597
1598
|
properties[name] = result
|
|
1598
1599
|
offset += size
|
|
@@ -1688,13 +1689,11 @@ module AMQ
|
|
|
1688
1689
|
@index = 0x003C0015 # 60, 21, 3932181
|
|
1689
1690
|
@packed_indexes = [60, 21].pack(PACK_UINT16_X2).freeze
|
|
1690
1691
|
|
|
1692
|
+
# Optimized decode using getbyte
|
|
1691
1693
|
# @return
|
|
1692
1694
|
def self.decode(data)
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
offset += 1
|
|
1696
|
-
consumer_tag = data[offset, length]
|
|
1697
|
-
offset += length
|
|
1695
|
+
length = data.getbyte(0)
|
|
1696
|
+
consumer_tag = data.byteslice(1, length)
|
|
1698
1697
|
self.new(consumer_tag)
|
|
1699
1698
|
end
|
|
1700
1699
|
|
|
@@ -1866,26 +1865,25 @@ module AMQ
|
|
|
1866
1865
|
@index = 0x003C003C # 60, 60, 3932220
|
|
1867
1866
|
@packed_indexes = [60, 60].pack(PACK_UINT16_X2).freeze
|
|
1868
1867
|
|
|
1868
|
+
# Optimized decode using getbyte and unpack1 for better performance
|
|
1869
1869
|
# @return
|
|
1870
1870
|
def self.decode(data)
|
|
1871
|
-
offset =
|
|
1872
|
-
length = data
|
|
1871
|
+
offset = 0
|
|
1872
|
+
length = data.getbyte(offset)
|
|
1873
1873
|
offset += 1
|
|
1874
|
-
consumer_tag = data
|
|
1874
|
+
consumer_tag = data.byteslice(offset, length)
|
|
1875
1875
|
offset += length
|
|
1876
|
-
delivery_tag =
|
|
1876
|
+
delivery_tag = data.byteslice(offset, 8).unpack1(PACK_UINT64_BE)
|
|
1877
1877
|
offset += 8
|
|
1878
|
-
|
|
1878
|
+
redelivered = (data.getbyte(offset) & 1) != 0
|
|
1879
1879
|
offset += 1
|
|
1880
|
-
|
|
1881
|
-
length = data[offset, 1].unpack(PACK_CHAR).first
|
|
1880
|
+
length = data.getbyte(offset)
|
|
1882
1881
|
offset += 1
|
|
1883
|
-
exchange = data
|
|
1882
|
+
exchange = data.byteslice(offset, length)
|
|
1884
1883
|
offset += length
|
|
1885
|
-
length = data
|
|
1884
|
+
length = data.getbyte(offset)
|
|
1886
1885
|
offset += 1
|
|
1887
|
-
routing_key = data
|
|
1888
|
-
offset += length
|
|
1886
|
+
routing_key = data.byteslice(offset, length)
|
|
1889
1887
|
self.new(consumer_tag, delivery_tag, redelivered, exchange, routing_key)
|
|
1890
1888
|
end
|
|
1891
1889
|
|
|
@@ -2009,14 +2007,11 @@ module AMQ
|
|
|
2009
2007
|
@index = 0x003C0050 # 60, 80, 3932240
|
|
2010
2008
|
@packed_indexes = [60, 80].pack(PACK_UINT16_X2).freeze
|
|
2011
2009
|
|
|
2010
|
+
# Optimized decode using unpack1 and getbyte
|
|
2012
2011
|
# @return
|
|
2013
2012
|
def self.decode(data)
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
offset += 8
|
|
2017
|
-
bit_buffer = data[offset, 1].unpack(PACK_CHAR).first
|
|
2018
|
-
offset += 1
|
|
2019
|
-
multiple = (bit_buffer & (1 << 0)) != 0
|
|
2013
|
+
delivery_tag = data.byteslice(0, 8).unpack1(PACK_UINT64_BE)
|
|
2014
|
+
multiple = (data.getbyte(8) & 1) != 0
|
|
2020
2015
|
self.new(delivery_tag, multiple)
|
|
2021
2016
|
end
|
|
2022
2017
|
|
|
@@ -2141,15 +2136,13 @@ module AMQ
|
|
|
2141
2136
|
@index = 0x003C0078 # 60, 120, 3932280
|
|
2142
2137
|
@packed_indexes = [60, 120].pack(PACK_UINT16_X2).freeze
|
|
2143
2138
|
|
|
2139
|
+
# Optimized decode using unpack1 and getbyte
|
|
2144
2140
|
# @return
|
|
2145
2141
|
def self.decode(data)
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
offset += 1
|
|
2151
|
-
multiple = (bit_buffer & (1 << 0)) != 0
|
|
2152
|
-
requeue = (bit_buffer & (1 << 1)) != 0
|
|
2142
|
+
delivery_tag = data.byteslice(0, 8).unpack1(PACK_UINT64_BE)
|
|
2143
|
+
bit_buffer = data.getbyte(8)
|
|
2144
|
+
multiple = (bit_buffer & 1) != 0
|
|
2145
|
+
requeue = (bit_buffer & 2) != 0
|
|
2153
2146
|
self.new(delivery_tag, multiple, requeue)
|
|
2154
2147
|
end
|
|
2155
2148
|
|
data/lib/amq/protocol/frame.rb
CHANGED
|
@@ -60,9 +60,11 @@ This functionality is part of the https://github.com/ruby-amqp/amq-client librar
|
|
|
60
60
|
EOF
|
|
61
61
|
end
|
|
62
62
|
|
|
63
|
+
# Optimized header decode using unpack1 for single values where appropriate
|
|
63
64
|
def self.decode_header(header)
|
|
64
65
|
raise EmptyResponseError if header == nil || header.empty?
|
|
65
66
|
|
|
67
|
+
# Use unpack for multiple values - this is the optimal approach
|
|
66
68
|
type_id, channel, size = header.unpack(PACK_CHAR_UINT16_UINT32)
|
|
67
69
|
type = TYPES_REVERSE[type_id]
|
|
68
70
|
raise FrameTypeError.new(TYPES_OPTIONS) unless type
|
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: 2.
|
|
4
|
+
version: 2.5.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jakub Stastny
|
|
@@ -10,7 +10,7 @@ authors:
|
|
|
10
10
|
- Mark Abramov
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date:
|
|
13
|
+
date: 2026-01-20 00:00:00.000000000 Z
|
|
14
14
|
dependencies: []
|
|
15
15
|
description: |2
|
|
16
16
|
amq-protocol is an AMQP 0.9.1 serialization library for Ruby. It is not a
|
|
@@ -22,32 +22,9 @@ extensions: []
|
|
|
22
22
|
extra_rdoc_files:
|
|
23
23
|
- README.md
|
|
24
24
|
files:
|
|
25
|
-
- ".github/ISSUE_TEMPLATE.md"
|
|
26
|
-
- ".github/workflows/ci.yml"
|
|
27
|
-
- ".gitignore"
|
|
28
|
-
- ".gitmodules"
|
|
29
|
-
- ".rspec"
|
|
30
|
-
- ".travis.yml"
|
|
31
25
|
- ChangeLog.md
|
|
32
|
-
- Gemfile
|
|
33
26
|
- LICENSE
|
|
34
27
|
- README.md
|
|
35
|
-
- Rakefile
|
|
36
|
-
- amq-protocol.gemspec
|
|
37
|
-
- benchmarks/frame_encoding.rb
|
|
38
|
-
- benchmarks/int_allocator.rb
|
|
39
|
-
- benchmarks/method_encoding.rb
|
|
40
|
-
- benchmarks/pack_unpack.rb
|
|
41
|
-
- benchmarks/pure/body_framing_with_256k_payload.rb
|
|
42
|
-
- benchmarks/pure/body_framing_with_2k_payload.rb
|
|
43
|
-
- benchmarks/run_all.rb
|
|
44
|
-
- benchmarks/table_encoding.rb
|
|
45
|
-
- codegen/__init__.py
|
|
46
|
-
- codegen/amqp_0.9.1_changes.json
|
|
47
|
-
- codegen/codegen.py
|
|
48
|
-
- codegen/codegen_helpers.py
|
|
49
|
-
- codegen/protocol.rb.pytemplate
|
|
50
|
-
- generate.rb
|
|
51
28
|
- lib/amq/bit_set.rb
|
|
52
29
|
- lib/amq/endianness.rb
|
|
53
30
|
- lib/amq/int_allocator.rb
|
|
@@ -65,32 +42,6 @@ files:
|
|
|
65
42
|
- lib/amq/protocol/version.rb
|
|
66
43
|
- lib/amq/settings.rb
|
|
67
44
|
- lib/amq/uri.rb
|
|
68
|
-
- profiling/README.md
|
|
69
|
-
- profiling/stackprof/body_framing_with_2k_payload.rb
|
|
70
|
-
- spec/amq/bit_set_spec.rb
|
|
71
|
-
- spec/amq/endianness_spec.rb
|
|
72
|
-
- spec/amq/int_allocator_spec.rb
|
|
73
|
-
- spec/amq/pack_spec.rb
|
|
74
|
-
- spec/amq/protocol/basic_spec.rb
|
|
75
|
-
- spec/amq/protocol/blank_body_encoding_spec.rb
|
|
76
|
-
- spec/amq/protocol/channel_spec.rb
|
|
77
|
-
- spec/amq/protocol/confirm_spec.rb
|
|
78
|
-
- spec/amq/protocol/connection_spec.rb
|
|
79
|
-
- spec/amq/protocol/constants_spec.rb
|
|
80
|
-
- spec/amq/protocol/exceptions_spec.rb
|
|
81
|
-
- spec/amq/protocol/exchange_spec.rb
|
|
82
|
-
- spec/amq/protocol/float_32bit_spec.rb
|
|
83
|
-
- spec/amq/protocol/frame_spec.rb
|
|
84
|
-
- spec/amq/protocol/method_spec.rb
|
|
85
|
-
- spec/amq/protocol/queue_spec.rb
|
|
86
|
-
- spec/amq/protocol/table_spec.rb
|
|
87
|
-
- spec/amq/protocol/tx_spec.rb
|
|
88
|
-
- spec/amq/protocol/value_decoder_spec.rb
|
|
89
|
-
- spec/amq/protocol/value_encoder_spec.rb
|
|
90
|
-
- spec/amq/protocol_spec.rb
|
|
91
|
-
- spec/amq/settings_spec.rb
|
|
92
|
-
- spec/amq/uri_parsing_spec.rb
|
|
93
|
-
- spec/spec_helper.rb
|
|
94
45
|
homepage: http://github.com/ruby-amqp/amq-protocol
|
|
95
46
|
licenses:
|
|
96
47
|
- MIT
|
|
@@ -109,7 +60,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
109
60
|
- !ruby/object:Gem::Version
|
|
110
61
|
version: '0'
|
|
111
62
|
requirements: []
|
|
112
|
-
rubygems_version: 3.6.
|
|
63
|
+
rubygems_version: 3.6.2
|
|
113
64
|
specification_version: 4
|
|
114
65
|
summary: AMQP 0.9.1 encoding & decoding library.
|
|
115
66
|
test_files: []
|
data/.github/ISSUE_TEMPLATE.md
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
## Does This Really Belong to GitHub issues?
|
|
2
|
-
|
|
3
|
-
If you find a bug you understand well, poor default, incorrect or unclear piece of documentation,
|
|
4
|
-
or missing feature, please [file an
|
|
5
|
-
issue](http://github.com/ruby-amqp/bunny/issues) on GitHub.
|
|
6
|
-
|
|
7
|
-
Please use [Bunny's mailing list](http://groups.google.com/group/ruby-amqp) for questions,
|
|
8
|
-
investigations, and discussions. GitHub issues should be used for specific, well understood, actionable
|
|
9
|
-
maintainers and contributors can work on.
|
|
10
|
-
|
|
11
|
-
When filing an issue, please specify
|
|
12
|
-
|
|
13
|
-
* Which Bunny and RabbitMQ versions are used
|
|
14
|
-
* Recent RabbitMQ log file contents
|
|
15
|
-
* Full exception stack traces
|
|
16
|
-
* Steps to reproduce or a failing test case
|
|
17
|
-
|
|
18
|
-
This would greatly help the maintainers help you.
|
data/.github/workflows/ci.yml
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
name: CI
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches:
|
|
6
|
-
- "main"
|
|
7
|
-
pull_request:
|
|
8
|
-
branches:
|
|
9
|
-
- "main"
|
|
10
|
-
|
|
11
|
-
jobs:
|
|
12
|
-
test:
|
|
13
|
-
runs-on: ubuntu-latest
|
|
14
|
-
|
|
15
|
-
strategy:
|
|
16
|
-
matrix:
|
|
17
|
-
ruby-version:
|
|
18
|
-
- "3.4.2"
|
|
19
|
-
- "3.3.7"
|
|
20
|
-
- "3.2.7"
|
|
21
|
-
|
|
22
|
-
steps:
|
|
23
|
-
- uses: actions/checkout@v4
|
|
24
|
-
- name: Set up Ruby ${{ matrix.ruby-version }}
|
|
25
|
-
uses: ruby/setup-ruby@v1
|
|
26
|
-
with:
|
|
27
|
-
ruby-version: ${{ matrix.ruby-version }}
|
|
28
|
-
- name: Install dependencies
|
|
29
|
-
run: bundle install
|
|
30
|
-
- name: Run tests
|
|
31
|
-
run: bundle exec rspec -c
|
data/.gitignore
DELETED
data/.gitmodules
DELETED
data/.rspec
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
--require spec_helper
|
data/.travis.yml
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
dist: bionic
|
|
2
|
-
language: ruby
|
|
3
|
-
bundler_args: --without development
|
|
4
|
-
cache: bundler
|
|
5
|
-
script: "bundle exec rspec spec"
|
|
6
|
-
rvm:
|
|
7
|
-
- ruby-head
|
|
8
|
-
- "2.6.3"
|
|
9
|
-
- "2.5.5"
|
|
10
|
-
- "2.4.5"
|
|
11
|
-
- "2.3.8"
|
|
12
|
-
notifications:
|
|
13
|
-
recipients:
|
|
14
|
-
- michael@rabbitmq.com
|
|
15
|
-
matrix:
|
|
16
|
-
allow_failures:
|
|
17
|
-
- rvm: ruby-head
|
data/Gemfile
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
|
|
3
|
-
source "https://rubygems.org"
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
group :development do
|
|
7
|
-
# excludes Windows, Rubinius and JRuby
|
|
8
|
-
gem "ruby-prof", :platforms => [:mri_19, :mri_20, :mri_21]
|
|
9
|
-
|
|
10
|
-
gem "rake"
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
group :benchmark do
|
|
14
|
-
gem "benchmark-ips", "~> 2.12"
|
|
15
|
-
gem "benchmark-memory", "~> 0.2"
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
group :test do
|
|
19
|
-
gem "rspec", ">= 3.8.0"
|
|
20
|
-
gem "rspec-its"
|
|
21
|
-
gem "simplecov"
|
|
22
|
-
gem 'bigdecimal'
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
group :development, :test do
|
|
26
|
-
gem "byebug"
|
|
27
|
-
end
|
data/Rakefile
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
require "bundler"
|
|
2
|
-
Bundler.setup
|
|
3
|
-
|
|
4
|
-
require "rake"
|
|
5
|
-
require "rspec/core/rake_task"
|
|
6
|
-
|
|
7
|
-
$LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
|
|
8
|
-
require "amq/protocol/version"
|
|
9
|
-
|
|
10
|
-
task :gem => :build
|
|
11
|
-
task :build do
|
|
12
|
-
system "gem build amq-protocol.gemspec"
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
task :install => :build do
|
|
16
|
-
system "gem install amq-protocol-#{AMQ::Protocol::VERSION}.gem"
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def extension
|
|
20
|
-
RUBY_PLATFORM =~ /darwin/ ? "bundle" : "so"
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def compile!
|
|
24
|
-
puts "Compiling native extensions..."
|
|
25
|
-
Dir.chdir(Pathname(__FILE__).dirname + "ext/") do
|
|
26
|
-
`bundle exec ruby extconf.rb`
|
|
27
|
-
`make`
|
|
28
|
-
`cp client.#{extension} ../lib/amq/protocol/native/`
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
RSpec::Core::RakeTask.new("spec") do |spec|
|
|
33
|
-
spec.pattern = "spec/**/*_spec.rb"
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
RSpec::Core::RakeTask.new("clean_spec") do |spec|
|
|
37
|
-
spec.pattern = "spec/**/*_spec.rb"
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
task :compile do
|
|
41
|
-
compile!
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
task :clean do
|
|
45
|
-
puts "Cleaning out native extensions..."
|
|
46
|
-
begin
|
|
47
|
-
Dir.chdir(Pathname(__FILE__).dirname + "lib/amq-protocol/native") do
|
|
48
|
-
`rm client.#{extension}`
|
|
49
|
-
end
|
|
50
|
-
rescue Exception => e
|
|
51
|
-
puts e.message
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
task :default => [:compile, :spec, :clean, :clean_spec]
|
data/amq-protocol.gemspec
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env gem build
|
|
2
|
-
# encoding: utf-8
|
|
3
|
-
|
|
4
|
-
require "base64"
|
|
5
|
-
|
|
6
|
-
require File.expand_path("../lib/amq/protocol/version", __FILE__)
|
|
7
|
-
|
|
8
|
-
Gem::Specification.new do |s|
|
|
9
|
-
s.name = "amq-protocol"
|
|
10
|
-
s.version = AMQ::Protocol::VERSION
|
|
11
|
-
s.authors = ["Jakub Stastny", "Michael S. Klishin", "Theo Hultberg", "Mark Abramov"]
|
|
12
|
-
s.homepage = "http://github.com/ruby-amqp/amq-protocol"
|
|
13
|
-
s.summary = "AMQP 0.9.1 encoding & decoding library."
|
|
14
|
-
s.description = <<-DESC
|
|
15
|
-
amq-protocol is an AMQP 0.9.1 serialization library for Ruby. It is not a
|
|
16
|
-
client: the library only handles serialization and deserialization.
|
|
17
|
-
DESC
|
|
18
|
-
s.email = ["michael.s.klishin@gmail.com"]
|
|
19
|
-
s.licenses = ["MIT"]
|
|
20
|
-
s.required_ruby_version = Gem::Requirement.new(">= 2.2")
|
|
21
|
-
|
|
22
|
-
# files
|
|
23
|
-
s.files = `git ls-files`.split("\n").reject { |file| file =~ /^vendor\// }
|
|
24
|
-
s.require_paths = ["lib"]
|
|
25
|
-
|
|
26
|
-
s.extra_rdoc_files = ["README.md"] + Dir.glob("doc/*")
|
|
27
|
-
end
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
# encoding: utf-8
|
|
3
|
-
# frozen_string_literal: true
|
|
4
|
-
|
|
5
|
-
$LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), "..", "lib"))
|
|
6
|
-
|
|
7
|
-
require "amq/protocol/client"
|
|
8
|
-
require "benchmark/ips"
|
|
9
|
-
|
|
10
|
-
puts
|
|
11
|
-
puts "-" * 80
|
|
12
|
-
puts "Frame Encoding Benchmarks on #{RUBY_DESCRIPTION}"
|
|
13
|
-
puts "-" * 80
|
|
14
|
-
|
|
15
|
-
# Test data
|
|
16
|
-
SMALL_PAYLOAD = "x" * 100
|
|
17
|
-
MEDIUM_PAYLOAD = "x" * 1024
|
|
18
|
-
LARGE_PAYLOAD = "x" * 16384
|
|
19
|
-
|
|
20
|
-
CHANNEL = 1
|
|
21
|
-
|
|
22
|
-
Benchmark.ips do |x|
|
|
23
|
-
x.config(time: 5, warmup: 2)
|
|
24
|
-
|
|
25
|
-
x.report("Frame.encode(:method, small)") do
|
|
26
|
-
AMQ::Protocol::Frame.encode(:method, SMALL_PAYLOAD, CHANNEL)
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
x.report("Frame.encode(:method, medium)") do
|
|
30
|
-
AMQ::Protocol::Frame.encode(:method, MEDIUM_PAYLOAD, CHANNEL)
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
x.report("Frame.encode(:body, large)") do
|
|
34
|
-
AMQ::Protocol::Frame.encode(:body, LARGE_PAYLOAD, CHANNEL)
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
x.report("MethodFrame.new + encode") do
|
|
38
|
-
frame = AMQ::Protocol::MethodFrame.new(SMALL_PAYLOAD, CHANNEL)
|
|
39
|
-
frame.encode
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
x.report("BodyFrame.new + encode") do
|
|
43
|
-
frame = AMQ::Protocol::BodyFrame.new(MEDIUM_PAYLOAD, CHANNEL)
|
|
44
|
-
frame.encode
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
x.report("HeartbeatFrame.encode") do
|
|
48
|
-
AMQ::Protocol::HeartbeatFrame.encode
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
x.compare!
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
puts
|
|
55
|
-
puts "-" * 80
|
|
56
|
-
puts "Frame Header Decoding"
|
|
57
|
-
puts "-" * 80
|
|
58
|
-
|
|
59
|
-
# Encoded frame headers
|
|
60
|
-
METHOD_HEADER = [1, 0, 1, 0, 0, 0, 100].pack("CnN") # type=1, channel=1, size=100
|
|
61
|
-
BODY_HEADER = [3, 0, 5, 0, 0, 16, 0].pack("CnN") # type=3, channel=5, size=4096
|
|
62
|
-
|
|
63
|
-
Benchmark.ips do |x|
|
|
64
|
-
x.config(time: 5, warmup: 2)
|
|
65
|
-
|
|
66
|
-
x.report("Frame.decode_header (method)") do
|
|
67
|
-
AMQ::Protocol::Frame.decode_header(METHOD_HEADER)
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
x.report("Frame.decode_header (body)") do
|
|
71
|
-
AMQ::Protocol::Frame.decode_header(BODY_HEADER)
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
x.compare!
|
|
75
|
-
end
|
data/benchmarks/int_allocator.rb
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
$LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), "..", "lib"))
|
|
2
|
-
|
|
3
|
-
require 'amq/int_allocator'
|
|
4
|
-
require "benchmark"
|
|
5
|
-
|
|
6
|
-
allocator = AMQ::IntAllocator.new(1,65535)
|
|
7
|
-
mutex = Mutex.new
|
|
8
|
-
|
|
9
|
-
Benchmark.bm do |x|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
x.report("allocate") do
|
|
13
|
-
allocator = AMQ::IntAllocator.new(1,65535)
|
|
14
|
-
1.upto(65534) do |i|
|
|
15
|
-
mutex.synchronize do
|
|
16
|
-
n = allocator.allocate
|
|
17
|
-
raise 'it be broke' unless n == i
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
x.report("allocate_with_release") do
|
|
23
|
-
allocator = AMQ::IntAllocator.new(1,65535)
|
|
24
|
-
1.upto(65534) do |i|
|
|
25
|
-
mutex.synchronize do
|
|
26
|
-
n = allocator.allocate
|
|
27
|
-
if i % 5 == 0
|
|
28
|
-
allocator.release(n)
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
end
|