bunny 2.0.0.rc2 → 2.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e0c99fb0a3faf8edcc73da84f74ce724e77b71a1
4
- data.tar.gz: 4c50a4aa3b4b6bb70ae4f9f8d4305914c24e9f1b
3
+ metadata.gz: a03370c05bd0085362a6eb7776c5f8bac7baa228
4
+ data.tar.gz: f23f3d9759ac91de7a9f43a17ca4681aa9da9192
5
5
  SHA512:
6
- metadata.gz: 717ee6c9d892e4d930464b2122ffbd2059420553c4b3f3ec670d6b66331d9885feeac96eb0edf7f2da1fcf11ef77bc05e3b2beacfbb7f96a19a7e780b2fb3ea5
7
- data.tar.gz: 3b24edbe00fbbb46a20592bb5cc28bc5f00fa6fb05180a5b91405f2534c9c4a8d8e3b0b9ab12e1f6213a501f3cc2cab374e00a3bc3a31ba79281efa7e9e0a8d1
6
+ metadata.gz: 1beba2d8994c8d8a977a19085d62dc4afe5d319bf5768aad48b145636fe0217b6a7e3dacb5f2a0b0161609d291c4a6fc9bc5856dfbfbbe741f28eea5416d8ca0
7
+ data.tar.gz: 3639354508b8bb3b0e637372a6c4b6295a7422d15b09354604c3c00af7db55a70d866d39170b4fac4f06ae1b82f7658749152e6b99d90f77db18e1dabb96f105
@@ -55,6 +55,14 @@ Since `basic.qos`'s `prefetch_count` field is of type `short` in the protocol,
55
55
  Bunny must enforce its maximum allowed value to `2^16 - 1` to avoid
56
56
  confusing issues due to overflow.
57
57
 
58
+ ### Per-Consumer and Per-Channel Prefetch
59
+
60
+ Recent RabbitMQ versions support `basic.qos` `global` flag, controlling whether
61
+ `prefetch` applies per-consumer or per-channel. Bunny `Channel#prefetch` now
62
+ allows flag to be set as optional parameter, with the same default behaviour as
63
+ before (per-consumer).
64
+
65
+ Contributed by tiredpixel.
58
66
 
59
67
 
60
68
  ## Changes between Bunny 1.6.0 and 1.7.0
data/README.md CHANGED
@@ -194,10 +194,14 @@ contributing failing test cases.
194
194
 
195
195
  ### Running the Specs
196
196
 
197
- The cleanest way to get the specs running is by starting a clean rabbitmq server
198
- node on your machine specifically for the bunny specs.
197
+ The specs require RabbitMQ to be running locally with a specific set of vhosts
198
+ and users. RabbitMQ can be provisioned and started any that's convenient to you
199
+ as long as it has a suitable TLS keys configuration and management plugin enabled.
200
+ Make sure you have a recent version of RabbitMQ (> `3.5.3`).
199
201
 
200
- Make sure you have a recent version of RabbitMQ (> 3.4) and run the following command
202
+ You can also start a clean RabbitMQ server
203
+ node on your machine specifically for the bunny specs.
204
+ To do so, run the following command
201
205
  from the base directory of the gem:
202
206
 
203
207
  ```
@@ -206,16 +210,16 @@ RABBITMQ_NODENAME=bunny RABBITMQ_CONFIG_FILE=./spec/config/rabbitmq RABBITMQ_ENA
206
210
 
207
211
  The specs use the RabbitMQ management plugin and require a TLS port to be available. The config files in the spec/config directory enable these.
208
212
 
209
- Next up you'll need to prepare your node for the specs (Only once):
213
+ Next up you'll need to prepare your node for the specs (just once):
210
214
 
211
215
  ```
212
216
  RABBITMQ_NODENAME=bunny ./bin/ci/before_build
213
217
  ```
214
218
 
215
- And then run the specs:
219
+ And then run the core integration suite:
216
220
 
217
221
  ```
218
- RABBITMQ_NODENAME=bunny rspec
222
+ RABBITMQ_NODENAME=bunny CI=true rspec
219
223
  ```
220
224
 
221
225
  ## Other Ruby RabbitMQ Clients
@@ -156,6 +156,8 @@ module Bunny
156
156
 
157
157
  # @return [Integer] active basic.qos prefetch value
158
158
  attr_reader :prefetch_count
159
+ # @return [Integer] active basic.qos prefetch global mode
160
+ attr_reader :prefetch_global
159
161
 
160
162
  DEFAULT_CONTENT_TYPE = "application/octet-stream".freeze
161
163
  SHORTSTR_LIMIT = 255
@@ -429,11 +431,20 @@ module Bunny
429
431
  # have to acknowledge or reject one of the previously consumed messages
430
432
  #
431
433
  # @param [Integer] prefetch_count Prefetch (QoS setting) for this channel
434
+ # @param [Boolean] global
435
+ # Whether to use global mode for prefetch:
436
+ # - +false+: per-consumer
437
+ # - +true+: per-channel
438
+ # Note that the default value (+false+) hasn't actually changed, but
439
+ # previous documentation described that as meaning per-channel and
440
+ # unsupported in RabbitMQ, whereas it now actually appears to mean
441
+ # per-consumer and supported
442
+ # (https://www.rabbitmq.com/consumer-prefetch.html).
432
443
  # @see http://rubybunny.info/articles/exchanges.html Exchanges and Publishing guide
433
444
  # @see http://rubybunny.info/articles/queues.html Queues and Consumers guide
434
445
  # @api public
435
- def prefetch(count)
436
- self.basic_qos(count, false)
446
+ def prefetch(count, global = false)
447
+ self.basic_qos(count, global)
437
448
  end
438
449
 
439
450
  # Flow control. When set to false, RabbitMQ will stop delivering messages on this
@@ -624,7 +635,15 @@ module Bunny
624
635
  #
625
636
  # @param [Integer] prefetch_count How many messages can consumers on this channel be given at a time
626
637
  # (before they have to acknowledge or reject one of the earlier received messages)
627
- # @param [Boolean] global (false) Ignored, as it is not supported by RabbitMQ
638
+ # @param [Boolean] global
639
+ # Whether to use global mode for prefetch:
640
+ # - +false+: per-consumer
641
+ # - +true+: per-channel
642
+ # Note that the default value (+false+) hasn't actually changed, but
643
+ # previous documentation described that as meaning per-channel and
644
+ # unsupported in RabbitMQ, whereas it now actually appears to mean
645
+ # per-consumer and supported
646
+ # (https://www.rabbitmq.com/consumer-prefetch.html).
628
647
  # @return [AMQ::Protocol::Basic::QosOk] RabbitMQ response
629
648
  # @see Bunny::Channel#prefetch
630
649
  # @see http://rubybunny.info/articles/queues.html Queues and Consumers guide
@@ -641,7 +660,8 @@ module Bunny
641
660
  end
642
661
  raise_if_continuation_resulted_in_a_channel_error!
643
662
 
644
- @prefetch_count = count
663
+ @prefetch_count = count
664
+ @prefetch_global = global
645
665
 
646
666
  @last_basic_qos_ok
647
667
  end
@@ -1486,7 +1506,7 @@ module Bunny
1486
1506
  #
1487
1507
  # @api plugin
1488
1508
  def recover_prefetch_setting
1489
- basic_qos(@prefetch_count) if @prefetch_count
1509
+ basic_qos(@prefetch_count, @prefetch_global) if @prefetch_count
1490
1510
  end
1491
1511
 
1492
1512
  # Recovers publisher confirms mode. Used by the Automatic Network Failure
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Bunny
4
4
  # @return [String] Version of the library
5
- VERSION = "2.0.0.rc2"
5
+ VERSION = "2.0.0"
6
6
  end
@@ -14,7 +14,20 @@ describe Bunny::Channel, "#prefetch" do
14
14
  context "with a positive integer < 65535" do
15
15
  it "sets that prefetch level via basic.qos" do
16
16
  ch = connection.create_channel
17
+ expect(ch.prefetch_count).not_to eq 10
18
+ expect(ch.prefetch_global).to be_nil
17
19
  expect(ch.prefetch(10)).to be_instance_of(AMQ::Protocol::Basic::QosOk)
20
+ expect(ch.prefetch_count).to eq 10
21
+ expect(ch.prefetch_global).to be false
22
+ end
23
+
24
+ it "sets that prefetch global via basic.qos" do
25
+ ch = connection.create_channel
26
+ expect(ch.prefetch_count).not_to eq 42
27
+ expect(ch.prefetch_global).to be_nil
28
+ expect(ch.prefetch(42, true)).to be_instance_of(AMQ::Protocol::Basic::QosOk)
29
+ expect(ch.prefetch_count).to eq 42
30
+ expect(ch.prefetch_global).to be true
18
31
  end
19
32
  end
20
33
 
@@ -172,6 +172,7 @@ unless ENV["CI"]
172
172
  ch = c.create_channel
173
173
  ch.prefetch(11)
174
174
  expect(ch.prefetch_count).to eq 11
175
+ expect(ch.prefetch_global).to be false
175
176
  close_all_connections!
176
177
  sleep 0.1
177
178
  expect(c).not_to be_open
@@ -179,9 +180,26 @@ unless ENV["CI"]
179
180
  wait_for_recovery
180
181
  expect(ch).to be_open
181
182
  expect(ch.prefetch_count).to eq 11
183
+ expect(ch.prefetch_global).to be false
182
184
  end
183
185
  end
184
186
 
187
+ it "recovers basic.qos prefetch global setting" do
188
+ with_open do |c|
189
+ ch = c.create_channel
190
+ ch.prefetch(42, true)
191
+ expect(ch.prefetch_count).to eq 42
192
+ expect(ch.prefetch_global).to be true
193
+ close_all_connections!
194
+ sleep 0.1
195
+ expect(c).not_to be_open
196
+
197
+ wait_for_recovery
198
+ expect(ch).to be_open
199
+ expect(ch.prefetch_count).to eq 42
200
+ expect(ch.prefetch_global).to be true
201
+ end
202
+ end
185
203
 
186
204
  it "recovers publisher confirms setting" do
187
205
  with_open do |c|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bunny
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.rc2
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Duncan
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2015-06-26 00:00:00.000000000 Z
15
+ date: 2015-07-23 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: amq-protocol
@@ -227,12 +227,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
227
227
  version: '0'
228
228
  required_rubygems_version: !ruby/object:Gem::Requirement
229
229
  requirements:
230
- - - ">"
230
+ - - ">="
231
231
  - !ruby/object:Gem::Version
232
- version: 1.3.1
232
+ version: '0'
233
233
  requirements: []
234
234
  rubyforge_project:
235
- rubygems_version: 2.4.5
235
+ rubygems_version: 2.4.6
236
236
  signing_key:
237
237
  specification_version: 4
238
238
  summary: Popular easy to use Ruby client for RabbitMQ