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.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog.md +12 -5
  3. data/lib/amq/protocol/client.rb +30 -37
  4. data/lib/amq/protocol/frame.rb +2 -0
  5. data/lib/amq/protocol/version.rb +1 -1
  6. metadata +3 -52
  7. data/.github/ISSUE_TEMPLATE.md +0 -18
  8. data/.github/workflows/ci.yml +0 -31
  9. data/.gitignore +0 -18
  10. data/.gitmodules +0 -3
  11. data/.rspec +0 -1
  12. data/.travis.yml +0 -17
  13. data/Gemfile +0 -27
  14. data/Rakefile +0 -55
  15. data/amq-protocol.gemspec +0 -27
  16. data/benchmarks/frame_encoding.rb +0 -75
  17. data/benchmarks/int_allocator.rb +0 -34
  18. data/benchmarks/method_encoding.rb +0 -198
  19. data/benchmarks/pack_unpack.rb +0 -158
  20. data/benchmarks/pure/body_framing_with_256k_payload.rb +0 -28
  21. data/benchmarks/pure/body_framing_with_2k_payload.rb +0 -28
  22. data/benchmarks/run_all.rb +0 -64
  23. data/benchmarks/table_encoding.rb +0 -110
  24. data/codegen/__init__.py +0 -0
  25. data/codegen/amqp_0.9.1_changes.json +0 -1
  26. data/codegen/codegen.py +0 -151
  27. data/codegen/codegen_helpers.py +0 -162
  28. data/codegen/protocol.rb.pytemplate +0 -320
  29. data/generate.rb +0 -24
  30. data/profiling/README.md +0 -9
  31. data/profiling/stackprof/body_framing_with_2k_payload.rb +0 -33
  32. data/spec/amq/bit_set_spec.rb +0 -249
  33. data/spec/amq/endianness_spec.rb +0 -23
  34. data/spec/amq/int_allocator_spec.rb +0 -136
  35. data/spec/amq/pack_spec.rb +0 -58
  36. data/spec/amq/protocol/basic_spec.rb +0 -325
  37. data/spec/amq/protocol/blank_body_encoding_spec.rb +0 -9
  38. data/spec/amq/protocol/channel_spec.rb +0 -127
  39. data/spec/amq/protocol/confirm_spec.rb +0 -41
  40. data/spec/amq/protocol/connection_spec.rb +0 -146
  41. data/spec/amq/protocol/constants_spec.rb +0 -10
  42. data/spec/amq/protocol/exceptions_spec.rb +0 -70
  43. data/spec/amq/protocol/exchange_spec.rb +0 -106
  44. data/spec/amq/protocol/float_32bit_spec.rb +0 -27
  45. data/spec/amq/protocol/frame_spec.rb +0 -156
  46. data/spec/amq/protocol/method_spec.rb +0 -43
  47. data/spec/amq/protocol/queue_spec.rb +0 -126
  48. data/spec/amq/protocol/table_spec.rb +0 -291
  49. data/spec/amq/protocol/tx_spec.rb +0 -55
  50. data/spec/amq/protocol/value_decoder_spec.rb +0 -183
  51. data/spec/amq/protocol/value_encoder_spec.rb +0 -161
  52. data/spec/amq/protocol_spec.rb +0 -812
  53. data/spec/amq/settings_spec.rb +0 -58
  54. data/spec/amq/uri_parsing_spec.rb +0 -287
  55. data/spec/spec_helper.rb +0 -29
@@ -1,249 +0,0 @@
1
- require "amq/bit_set"
2
-
3
- # extracted from amqp gem. MK.
4
- RSpec.describe AMQ::BitSet do
5
-
6
- #
7
- # Environment
8
- #
9
-
10
- let(:nbits) { (1 << 16) - 1 }
11
-
12
-
13
- #
14
- # Examples
15
- #
16
-
17
- describe "#new" do
18
- it "has no bits set at the start" do
19
- bs = AMQ::BitSet.new(128)
20
- 0.upto(127) do |i|
21
- expect(bs[i]).to be_falsey
22
- end
23
- end # it
24
- end # describe
25
-
26
- describe "#word_index" do
27
- subject do
28
- described_class.new(nbits)
29
- end
30
- it "returns 0 when the word is between 0 and 63" do
31
- expect(subject.word_index(0)).to eq(0)
32
- expect(subject.word_index(63)).to eq(0)
33
- end # it
34
- it "returns 1 when the word is between 64 and 127" do
35
- expect(subject.word_index(64)).to be(1)
36
- expect(subject.word_index(127)).to be(1)
37
- end # it
38
- it "returns 2 when the word is between 128 and another number" do
39
- expect(subject.word_index(128)).to be(2)
40
- end # it
41
- end # describe
42
-
43
- describe "#get, #[]" do
44
- describe "when bit at given position is set" do
45
- subject do
46
- o = described_class.new(nbits)
47
- o.set(3)
48
- o
49
- end
50
-
51
- it "returns true" do
52
- expect(subject.get(3)).to be_truthy
53
- end # it
54
- end # describe
55
-
56
- describe "when bit at given position is off" do
57
- subject do
58
- described_class.new(nbits)
59
- end
60
-
61
- it "returns false" do
62
- expect(subject.get(5)).to be_falsey
63
- end # it
64
- end # describe
65
-
66
- describe "when index out of range" do
67
- subject do
68
- described_class.new(nbits)
69
- end
70
-
71
- it "should raise IndexError for negative index" do
72
- expect { subject.get(-1) }.to raise_error(IndexError)
73
- end # it
74
- it "should raise IndexError for index >= number of bits" do
75
- expect { subject.get(nbits) }.to raise_error(IndexError)
76
- end # it
77
- end # describe
78
- end # describe
79
-
80
-
81
- describe "#set" do
82
- describe "when bit at given position is set" do
83
- subject do
84
- described_class.new(nbits)
85
- end
86
-
87
- it "has no effect" do
88
- subject.set(3)
89
- expect(subject.get(3)).to be_truthy
90
- subject.set(3)
91
- expect(subject[3]).to be_truthy
92
- end # it
93
- end # describe
94
-
95
- describe "when bit at given position is off" do
96
- subject do
97
- described_class.new(nbits)
98
- end
99
-
100
- it "sets that bit" do
101
- subject.set(3)
102
- expect(subject.get(3)).to be_truthy
103
-
104
- subject.set(33)
105
- expect(subject.get(33)).to be_truthy
106
-
107
- subject.set(3387)
108
- expect(subject.get(3387)).to be_truthy
109
- end # it
110
- end # describe
111
-
112
- describe "when index out of range" do
113
- subject do
114
- described_class.new(nbits)
115
- end
116
-
117
- it "should raise IndexError for negative index" do
118
- expect { subject.set(-1) }.to raise_error(IndexError)
119
- end # it
120
- it "should raise IndexError for index >= number of bits" do
121
- expect { subject.set(nbits) }.to raise_error(IndexError)
122
- end # it
123
- end # describe
124
- end # describe
125
-
126
-
127
- describe "#unset" do
128
- describe "when bit at a given position is set" do
129
- subject do
130
- described_class.new(nbits)
131
- end
132
-
133
- it "unsets that bit" do
134
- subject.set(3)
135
- expect(subject.get(3)).to be_truthy
136
- subject.unset(3)
137
- expect(subject.get(3)).to be_falsey
138
- end # it
139
- end # describe
140
-
141
-
142
- describe "when bit at a given position is off" do
143
- subject do
144
- described_class.new(nbits)
145
- end
146
-
147
- it "has no effect" do
148
- expect(subject.get(3)).to be_falsey
149
- subject.unset(3)
150
- expect(subject.get(3)).to be_falsey
151
- end # it
152
- end # describe
153
-
154
- describe "when index out of range" do
155
- subject do
156
- described_class.new(nbits)
157
- end
158
-
159
- it "should raise IndexError for negative index" do
160
- expect { subject.unset(-1) }.to raise_error(IndexError)
161
- end # it
162
- it "should raise IndexError for index >= number of bits" do
163
- expect { subject.unset(nbits) }.to raise_error(IndexError)
164
- end # it
165
- end # describe
166
- end # describe
167
-
168
-
169
-
170
- describe "#clear" do
171
- subject do
172
- described_class.new(nbits)
173
- end
174
-
175
- it "clears all bits" do
176
- subject.set(3)
177
- expect(subject.get(3)).to be_truthy
178
-
179
- subject.set(7668)
180
- expect(subject.get(7668)).to be_truthy
181
-
182
- subject.clear
183
-
184
- expect(subject.get(3)).to be_falsey
185
- expect(subject.get(7668)).to be_falsey
186
- end # it
187
- end # describe
188
-
189
- describe "#number_of_trailing_ones" do
190
- it "calculates them" do
191
- expect(described_class.number_of_trailing_ones(0)).to eq(0)
192
- expect(described_class.number_of_trailing_ones(1)).to eq(1)
193
- expect(described_class.number_of_trailing_ones(2)).to eq(0)
194
- expect(described_class.number_of_trailing_ones(3)).to eq(2)
195
- expect(described_class.number_of_trailing_ones(4)).to eq(0)
196
- end # it
197
- end # describe
198
-
199
- describe '#next_clear_bit' do
200
- subject do
201
- described_class.new(255)
202
- end
203
- it "returns sequential values when none have been returned" do
204
- expect(subject.next_clear_bit).to eq(0)
205
- subject.set(0)
206
- expect(subject.next_clear_bit).to eq(1)
207
- subject.set(1)
208
- expect(subject.next_clear_bit).to eq(2)
209
- subject.unset(1)
210
- expect(subject.next_clear_bit).to eq(1)
211
- end # it
212
-
213
- it "returns the same number as long as nothing is set" do
214
- expect(subject.next_clear_bit).to eq(0)
215
- expect(subject.next_clear_bit).to eq(0)
216
- end # it
217
-
218
- it "handles more than 128 bits" do
219
- 0.upto(254) do |i|
220
- subject.set(i)
221
- expect(subject.next_clear_bit).to eq(i + 1)
222
- end
223
- subject.unset(254)
224
- expect(subject.get(254)).to be_falsey
225
- end # it
226
-
227
- it "returns -1 when all bits are set" do
228
- bs = described_class.new(64)
229
- 0.upto(63) { |i| bs.set(i) }
230
- expect(bs.next_clear_bit).to eq(-1)
231
- end
232
- end # describe
233
-
234
- describe "#to_s" do
235
- it "returns a string representation of the bit set" do
236
- bs = described_class.new(64)
237
- result = bs.to_s
238
- expect(result).to be_a(String)
239
- expect(result).to include(":")
240
- end
241
-
242
- it "shows set bits" do
243
- bs = described_class.new(64)
244
- bs.set(0)
245
- result = bs.to_s
246
- expect(result).to end_with("1:")
247
- end
248
- end # describe
249
- end
@@ -1,23 +0,0 @@
1
- # encoding: binary
2
-
3
- require "amq/endianness"
4
-
5
- RSpec.describe AMQ::Endianness do
6
- describe ".big_endian?" do
7
- it "returns a boolean" do
8
- expect([true, false]).to include(described_class.big_endian?)
9
- end
10
- end
11
-
12
- describe ".little_endian?" do
13
- it "returns the opposite of big_endian?" do
14
- expect(described_class.little_endian?).to eq(!described_class.big_endian?)
15
- end
16
- end
17
-
18
- describe "BIG_ENDIAN constant" do
19
- it "is a boolean" do
20
- expect([true, false]).to include(AMQ::Endianness::BIG_ENDIAN)
21
- end
22
- end
23
- end
@@ -1,136 +0,0 @@
1
- require "amq/int_allocator"
2
-
3
- RSpec.describe AMQ::IntAllocator do
4
-
5
- #
6
- # Environment
7
- #
8
-
9
- subject do
10
- described_class.new(1, 5)
11
- end
12
-
13
-
14
- #
15
- # Examples
16
- #
17
-
18
- describe "#initialize" do
19
- it "raises ArgumentError when hi <= lo" do
20
- expect { described_class.new(5, 5) }.to raise_error(ArgumentError)
21
- expect { described_class.new(10, 5) }.to raise_error(ArgumentError)
22
- end
23
- end
24
-
25
- describe "#number_of_bits" do
26
- it "returns number of bits available for allocation" do
27
- expect(subject.number_of_bits).to eq(4)
28
- end
29
- end
30
-
31
-
32
- describe "#hi" do
33
- it "returns upper bound of the allocation range" do
34
- expect(subject.hi).to eq(5)
35
- end
36
- end
37
-
38
- describe "#lo" do
39
- it "returns lower bound of the allocation range" do
40
- expect(subject.lo).to eq(1)
41
- end
42
- end
43
-
44
-
45
- describe "#allocate" do
46
- context "when integer in the range is available" do
47
- it "returns allocated integer" do
48
- expect(subject.allocate).to eq(1)
49
- expect(subject.allocate).to eq(2)
50
- expect(subject.allocate).to eq(3)
51
- expect(subject.allocate).to eq(4)
52
-
53
- expect(subject.allocate).to eq(-1)
54
- end
55
- end
56
-
57
- context "when integer in the range IS NOT available" do
58
- it "returns -1" do
59
- 4.times { subject.allocate }
60
-
61
- expect(subject.allocate).to eq(-1)
62
- expect(subject.allocate).to eq(-1)
63
- expect(subject.allocate).to eq(-1)
64
- expect(subject.allocate).to eq(-1)
65
- end
66
- end
67
- end
68
-
69
-
70
- describe "#free" do
71
- context "when the integer WAS allocated" do
72
- it "returns frees that integer" do
73
- 4.times { subject.allocate }
74
- expect(subject.allocate).to eq(-1)
75
-
76
- subject.free(1)
77
- expect(subject.allocate).to eq(1)
78
- expect(subject.allocate).to eq(-1)
79
- subject.free(2)
80
- expect(subject.allocate).to eq(2)
81
- expect(subject.allocate).to eq(-1)
82
- subject.free(3)
83
- expect(subject.allocate).to eq(3)
84
- expect(subject.allocate).to eq(-1)
85
- end
86
- end
87
-
88
- context "when the integer WAS NOT allocated" do
89
- it "has no effect" do
90
- 32.times { subject.free(1) }
91
- expect(subject.allocate).to eq(1)
92
- end
93
- end
94
- end
95
-
96
-
97
- describe "#allocated?" do
98
- context "when given position WAS allocated" do
99
- it "returns true" do
100
- 3.times { subject.allocate }
101
-
102
- expect(subject.allocated?(1)).to be_truthy
103
- expect(subject.allocated?(2)).to be_truthy
104
- expect(subject.allocated?(3)).to be_truthy
105
- end
106
- end
107
-
108
- context "when given position WAS NOT allocated" do
109
- it "returns false" do
110
- 2.times { subject.allocate }
111
-
112
- expect(subject.allocated?(3)).to be_falsey
113
- expect(subject.allocated?(4)).to be_falsey
114
- end
115
- end
116
- end
117
-
118
- describe "#release" do
119
- it "is an alias for #free" do
120
- subject.allocate
121
- expect(subject.allocated?(1)).to be_truthy
122
- subject.release(1)
123
- expect(subject.allocated?(1)).to be_falsey
124
- end
125
- end
126
-
127
- describe "#reset" do
128
- it "releases all allocations" do
129
- 4.times { subject.allocate }
130
- expect(subject.allocate).to eq(-1)
131
-
132
- subject.reset
133
- expect(subject.allocate).to eq(1)
134
- end
135
- end
136
- end
@@ -1,58 +0,0 @@
1
- # encoding: binary
2
-
3
- RSpec.describe AMQ::Pack do
4
- context "16-bit big-endian packing / unpacking" do
5
- let(:examples_16bit) {
6
- {
7
- 0x068D => "\x06\x8D", # 1677
8
- 0x0000 => "\x00\x00", # 0
9
- 0x7FFF => "\x7F\xFF" # 32767 (max positive signed 16-bit)
10
- }
11
- }
12
-
13
- it "packs signed integers into a big-endian string" do
14
- examples_16bit.each do |key, value|
15
- expect(described_class.pack_int16_big_endian(key)).to eq(value)
16
- end
17
- end
18
-
19
- it "unpacks signed integers from a string to a number" do
20
- examples_16bit.each do |key, value|
21
- expect(described_class.unpack_int16_big_endian(value)[0]).to eq(key)
22
- end
23
- end
24
- end
25
-
26
- context "64-bit big-endian packing / unpacking" do
27
- let(:examples) {
28
- {
29
- 0x0000000000000000 => "\x00\x00\x00\x00\x00\x00\x00\x00",
30
- 0x000000000000000A => "\x00\x00\x00\x00\x00\x00\x00\x0A",
31
- 0x00000000000000A0 => "\x00\x00\x00\x00\x00\x00\x00\xA0",
32
- 0x000000000000B0A0 => "\x00\x00\x00\x00\x00\x00\xB0\xA0",
33
- 0x00000000000CB0AD => "\x00\x00\x00\x00\x00\x0C\xB0\xAD",
34
- 0x8BADF00DDEFEC8ED => "\x8B\xAD\xF0\x0D\xDE\xFE\xC8\xED",
35
- 0x0D15EA5EFEE1DEAD => "\x0D\x15\xEA\x5E\xFE\xE1\xDE\xAD",
36
- 0xDEADBEEFDEADBABE => "\xDE\xAD\xBE\xEF\xDE\xAD\xBA\xBE"
37
- }
38
- }
39
-
40
- it "packs integers into big-endian string" do
41
- examples.each do |key, value|
42
- expect(described_class.pack_uint64_big_endian(key)).to eq(value)
43
- end
44
- end
45
-
46
- it "unpacks string representation into integer" do
47
- examples.each do |key, value|
48
- expect(described_class.unpack_uint64_big_endian(value)[0]).to eq(key)
49
- end
50
- end
51
- end
52
-
53
- describe "AMQ::Hacks alias" do
54
- it "is an alias for AMQ::Pack (backwards compatibility)" do
55
- expect(AMQ::Hacks).to eq(AMQ::Pack)
56
- end
57
- end
58
- end