amq-protocol 2.5.0 → 2.6.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.
- checksums.yaml +4 -4
- data/ChangeLog.md +21 -1
- data/LICENSE +1 -1
- data/lib/amq/protocol/channel_close.rb +24 -0
- data/lib/amq/protocol/version.rb +1 -1
- data/lib/amq/protocol.rb +1 -0
- metadata +3 -54
- 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/AGENTS.md +0 -23
- data/CLAUDE.md +0 -1
- data/GEMINI.md +0 -1
- 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: 0b58eb9e3a561cb4902e3a1b2526a47b68d4f0b5431f459fd87cce35cd6936bc
|
|
4
|
+
data.tar.gz: 21257ef030688922961fdeaf4a83d64b8ab3c21688e53c5fc41bf083b2277f1f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6e80602244a9d0768c9fbe24d16c0acc884205d9ebf41142bf69963dad829c60170b299b7b8ee43734299f7eb45be2d54b36ca58ef4de0196fc142bd68f70d3c
|
|
7
|
+
data.tar.gz: ea1f03bf20b010e0fbc23b1c8441ee6de0b71202b8f3b0a3a7b7574510b8a682eddcc7982caee8fbcb24c0b566bc6d9e67b485990ad40b67f291d8fbccadd0f9
|
data/ChangeLog.md
CHANGED
|
@@ -1,8 +1,28 @@
|
|
|
1
|
-
## Changes between 2.
|
|
1
|
+
## Changes between 2.6.0 and 2.7.0 (unreleased)
|
|
2
2
|
|
|
3
3
|
No changes yet.
|
|
4
4
|
|
|
5
5
|
|
|
6
|
+
## Changes between 2.5.1 and 2.6.0 (Mar 30, 2026)
|
|
7
|
+
|
|
8
|
+
### Channel.Close Predicate Methods
|
|
9
|
+
|
|
10
|
+
`Channel::Close` now provides predicate methods for identifying common
|
|
11
|
+
channel closure reasons by reply code and text:
|
|
12
|
+
|
|
13
|
+
* `#delivery_ack_timeout?`: consumer [delivery acknowledgement timeout](https://www.rabbitmq.com/docs/consumers#acknowledgement-timeout)
|
|
14
|
+
* `#unknown_delivery_tag?`: unknown delivery tag (e.g. [double ack](https://www.rabbitmq.com/docs/channels#error-handling))
|
|
15
|
+
* `#message_too_large?`: message exceeded the configured max size
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## Changes between 2.5.0 and 2.5.1 (Jan 19, 2026)
|
|
19
|
+
|
|
20
|
+
### Windows Installation Fixes
|
|
21
|
+
|
|
22
|
+
`2.4.0` and `2.5.0` versions unintentionally included files that were
|
|
23
|
+
symlinks, which caused installation on Windows to fail.
|
|
24
|
+
|
|
25
|
+
|
|
6
26
|
## Changes between 2.4.0 and 2.5.0 (Dec 31, 2025)
|
|
7
27
|
|
|
8
28
|
### Additional Consumer Hot Path Optimizations
|
data/LICENSE
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Copyright (c) 2010 – 2011 Jakub Šťastný aka Botanicus
|
|
2
|
-
Copyright (c) 2011 –
|
|
2
|
+
Copyright (c) 2011 – 2026 Michael S. Klishin <michael@defprotocol.org>
|
|
3
3
|
|
|
4
4
|
Permission is hereby granted, free of charge, to any person obtaining
|
|
5
5
|
a copy of this software and associated documentation files (the
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module AMQ
|
|
4
|
+
module Protocol
|
|
5
|
+
class Channel
|
|
6
|
+
class Close
|
|
7
|
+
# @return [Boolean] true if the channel was closed due to a consumer delivery acknowledgement timeout
|
|
8
|
+
def delivery_ack_timeout?
|
|
9
|
+
reply_code == 406 && reply_text =~ /delivery acknowledgement on channel \d+ timed out/
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# @return [Boolean] true if the channel was closed due to an unknown delivery tag (e.g. double ack)
|
|
13
|
+
def unknown_delivery_tag?
|
|
14
|
+
reply_code == 406 && reply_text =~ /unknown delivery tag/
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# @return [Boolean] true if the channel was closed because a message exceeded the configured max size
|
|
18
|
+
def message_too_large?
|
|
19
|
+
reply_code == 406 && reply_text =~ /larger than configured max size/
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
data/lib/amq/protocol/version.rb
CHANGED
data/lib/amq/protocol.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.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jakub Stastny
|
|
@@ -22,40 +22,15 @@ 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
|
-
- AGENTS.md
|
|
32
|
-
- CLAUDE.md
|
|
33
25
|
- ChangeLog.md
|
|
34
|
-
- GEMINI.md
|
|
35
|
-
- Gemfile
|
|
36
26
|
- LICENSE
|
|
37
27
|
- README.md
|
|
38
|
-
- Rakefile
|
|
39
|
-
- amq-protocol.gemspec
|
|
40
|
-
- benchmarks/frame_encoding.rb
|
|
41
|
-
- benchmarks/int_allocator.rb
|
|
42
|
-
- benchmarks/method_encoding.rb
|
|
43
|
-
- benchmarks/pack_unpack.rb
|
|
44
|
-
- benchmarks/pure/body_framing_with_256k_payload.rb
|
|
45
|
-
- benchmarks/pure/body_framing_with_2k_payload.rb
|
|
46
|
-
- benchmarks/run_all.rb
|
|
47
|
-
- benchmarks/table_encoding.rb
|
|
48
|
-
- codegen/__init__.py
|
|
49
|
-
- codegen/amqp_0.9.1_changes.json
|
|
50
|
-
- codegen/codegen.py
|
|
51
|
-
- codegen/codegen_helpers.py
|
|
52
|
-
- codegen/protocol.rb.pytemplate
|
|
53
|
-
- generate.rb
|
|
54
28
|
- lib/amq/bit_set.rb
|
|
55
29
|
- lib/amq/endianness.rb
|
|
56
30
|
- lib/amq/int_allocator.rb
|
|
57
31
|
- lib/amq/pack.rb
|
|
58
32
|
- lib/amq/protocol.rb
|
|
33
|
+
- lib/amq/protocol/channel_close.rb
|
|
59
34
|
- lib/amq/protocol/client.rb
|
|
60
35
|
- lib/amq/protocol/constants.rb
|
|
61
36
|
- lib/amq/protocol/exceptions.rb
|
|
@@ -68,32 +43,6 @@ files:
|
|
|
68
43
|
- lib/amq/protocol/version.rb
|
|
69
44
|
- lib/amq/settings.rb
|
|
70
45
|
- lib/amq/uri.rb
|
|
71
|
-
- profiling/README.md
|
|
72
|
-
- profiling/stackprof/body_framing_with_2k_payload.rb
|
|
73
|
-
- spec/amq/bit_set_spec.rb
|
|
74
|
-
- spec/amq/endianness_spec.rb
|
|
75
|
-
- spec/amq/int_allocator_spec.rb
|
|
76
|
-
- spec/amq/pack_spec.rb
|
|
77
|
-
- spec/amq/protocol/basic_spec.rb
|
|
78
|
-
- spec/amq/protocol/blank_body_encoding_spec.rb
|
|
79
|
-
- spec/amq/protocol/channel_spec.rb
|
|
80
|
-
- spec/amq/protocol/confirm_spec.rb
|
|
81
|
-
- spec/amq/protocol/connection_spec.rb
|
|
82
|
-
- spec/amq/protocol/constants_spec.rb
|
|
83
|
-
- spec/amq/protocol/exceptions_spec.rb
|
|
84
|
-
- spec/amq/protocol/exchange_spec.rb
|
|
85
|
-
- spec/amq/protocol/float_32bit_spec.rb
|
|
86
|
-
- spec/amq/protocol/frame_spec.rb
|
|
87
|
-
- spec/amq/protocol/method_spec.rb
|
|
88
|
-
- spec/amq/protocol/queue_spec.rb
|
|
89
|
-
- spec/amq/protocol/table_spec.rb
|
|
90
|
-
- spec/amq/protocol/tx_spec.rb
|
|
91
|
-
- spec/amq/protocol/value_decoder_spec.rb
|
|
92
|
-
- spec/amq/protocol/value_encoder_spec.rb
|
|
93
|
-
- spec/amq/protocol_spec.rb
|
|
94
|
-
- spec/amq/settings_spec.rb
|
|
95
|
-
- spec/amq/uri_parsing_spec.rb
|
|
96
|
-
- spec/spec_helper.rb
|
|
97
46
|
homepage: http://github.com/ruby-amqp/amq-protocol
|
|
98
47
|
licenses:
|
|
99
48
|
- MIT
|
|
@@ -112,7 +61,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
112
61
|
- !ruby/object:Gem::Version
|
|
113
62
|
version: '0'
|
|
114
63
|
requirements: []
|
|
115
|
-
rubygems_version: 3.6.
|
|
64
|
+
rubygems_version: 3.6.7
|
|
116
65
|
specification_version: 4
|
|
117
66
|
summary: AMQP 0.9.1 encoding & decoding library.
|
|
118
67
|
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/AGENTS.md
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
# Instructions for AI Agents
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
|
|
5
|
-
This is a pure Ruby implementation of a AMQP 0-9-1 protocol parser
|
|
6
|
-
(more specifically% serialization, deserialization, framing) used by
|
|
7
|
-
[Bunny](https://github.com/ruby-amqp/bunny), a Ruby AMQP 0-9-1 client for RabbitMQ.
|
|
8
|
-
|
|
9
|
-
## Target Ruby Version
|
|
10
|
-
|
|
11
|
-
This library targets Ruby 3.0 and later versions.
|
|
12
|
-
|
|
13
|
-
## Comments
|
|
14
|
-
|
|
15
|
-
* Only add very important comments, both in tests and in the implementation
|
|
16
|
-
|
|
17
|
-
## Git Instructions
|
|
18
|
-
|
|
19
|
-
* Never add yourself to the list of commit co-authors
|
|
20
|
-
|
|
21
|
-
## Style Guide
|
|
22
|
-
|
|
23
|
-
* Never add full stops to Markdown list items
|
data/CLAUDE.md
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
AGENTS.md
|
data/GEMINI.md
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
AGENTS.md
|
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
|