bunny 3.0.0 → 3.1.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
  SHA256:
3
- metadata.gz: 420677d5395cc80a5ca3f5c553d9112ae947afb5d5dfef04f4d6ee95e3256b69
4
- data.tar.gz: 1305a730a263123d1cdb1aef37725b4021ffd76a26b77166242ecfb3f12f65eb
3
+ metadata.gz: d7cc272154254919de29ea5437f5eb13c3bff2fd16b229f2fae0939982d1fe27
4
+ data.tar.gz: 19720fa046ac8c06ca6c7e4bb3b450979b8f9537ed8cec7c6747a26428f14a8b
5
5
  SHA512:
6
- metadata.gz: '09f98c780d34e755191b9925517f724c1b3009c0de707899d86ad80a98732cc09cbb83f00a4e3bf7c68c9c8e481da21e9ae5c204fbb2c22790f1c70317b01840'
7
- data.tar.gz: 48c53d2fc69c737d1580e216df84273f18fff9018bdd6355dc439cf837a4f22998dc383088c84bae57eebf1c5476b08b8c7a21fb6fef2dd01c9eec0c4a7b9d63
6
+ metadata.gz: 1e604aa9511aac55434c1b458fab2ab67bb5cc454f3d8c2ada5bd910db20cb18c7382332e28e5b55d88478f7587688c80272063020ac2549fe37ee8902fade70
7
+ data.tar.gz: 182b111def73c1d0c25c6e4444a884703189ba7ba99c0bc39ba1db148f52210754a0da98f38ff161738db3dd647bbae5d3d78ba56dfaa6c54172803692fc58b7
data/README.md CHANGED
@@ -123,7 +123,9 @@ conn.start
123
123
 
124
124
  # open a channel
125
125
  ch = conn.create_channel
126
- ch.confirm_select
126
+ # enable publisher confirms with automatic tracking,
127
+ # see https://www.rabbitmq.com/docs/publishers#data-safety
128
+ ch.confirm_select(tracking: true)
127
129
 
128
130
  # declare a queue
129
131
  q = ch.queue("test1")
@@ -136,10 +138,6 @@ end
136
138
  # publish a message to the default exchange which then gets routed to this queue
137
139
  q.publish("Hello, everybody!")
138
140
 
139
- # await confirmations from RabbitMQ, see
140
- # https://www.rabbitmq.com/publishers.html#data-safety for details
141
- ch.wait_for_confirms
142
-
143
141
  # give the above consumer some time consume the delivery and print out the message
144
142
  sleep 1
145
143
 
data/lib/bunny/channel.rb CHANGED
@@ -339,6 +339,21 @@ module Bunny
339
339
  @status == :closed
340
340
  end
341
341
 
342
+ # @private
343
+ def connection_closed!
344
+ @status = :closed
345
+ end
346
+
347
+ # @private
348
+ def recovering!
349
+ @status = :recovering
350
+ end
351
+
352
+ # @private
353
+ def recovery_completed!
354
+ @status = :open
355
+ end
356
+
342
357
  #
343
358
  # @group Backwards compatibility with 0.8.0
344
359
  #
@@ -2250,7 +2265,9 @@ module Bunny
2250
2265
 
2251
2266
  # basic.ack, basic.reject, basic.nack. MK.
2252
2267
  if channel_level_exception_after_operation_that_has_no_response?(method)
2253
- @on_error.call(self, method) if @on_error
2268
+ # Runs outside the reader loop so that the callback can perform
2269
+ # blocking operations such as channel.reopen.
2270
+ Thread.new { @on_error.call(self, method) } if @on_error
2254
2271
  else
2255
2272
  @last_channel_error = instantiate_channel_level_exception(method)
2256
2273
  @continuations.push(method)
data/lib/bunny/session.rb CHANGED
@@ -817,6 +817,7 @@ module Bunny
817
817
  announce_network_failure_recovery
818
818
  @channel_mutex.synchronize do
819
819
  @channels.each do |n, ch|
820
+ ch.connection_closed!
820
821
  ch.maybe_kill_consumer_work_pool!
821
822
  end
822
823
  end
@@ -825,6 +826,7 @@ module Bunny
825
826
 
826
827
  recover_connection_and_channels
827
828
  recover_topology
829
+ mark_channels_after_recovery!
828
830
  notify_of_recovery_completion
829
831
  else
830
832
  @logger.error "Exception #{exception.message} is considered unrecoverable..."
@@ -1048,11 +1050,21 @@ module Bunny
1048
1050
  @channel_mutex.synchronize do
1049
1051
  @channels.each do |n, ch|
1050
1052
  ch.open
1053
+ ch.recovering!
1051
1054
  ch.recover_from_network_failure
1052
1055
  end
1053
1056
  end
1054
1057
  end
1055
1058
 
1059
+ # @private
1060
+ def mark_channels_after_recovery!
1061
+ @channel_mutex.synchronize do
1062
+ @channels.each do |n, ch|
1063
+ ch.recovery_completed!
1064
+ end
1065
+ end
1066
+ end
1067
+
1056
1068
  # @private
1057
1069
  def recover_topology
1058
1070
  @logger.debug "Will recover topology now"
data/lib/bunny/version.rb CHANGED
@@ -3,5 +3,5 @@
3
3
 
4
4
  module Bunny
5
5
  # @return [String] Version of the library
6
- VERSION = "3.0.0"
6
+ VERSION = "3.1.0"
7
7
  end
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: 3.0.0
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Duncan
@@ -127,7 +127,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
127
127
  requirements:
128
128
  - - ">="
129
129
  - !ruby/object:Gem::Version
130
- version: '2.5'
130
+ version: '3.0'
131
131
  required_rubygems_version: !ruby/object:Gem::Requirement
132
132
  requirements:
133
133
  - - ">="