bunny 2.21.0 → 2.22.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: a51dd17b606b2363463849ba249e8bdff82f263237304def85c72d804a72cf9f
4
- data.tar.gz: fc7754eb6f23de9759b515f9c98800ff24ecc0b1dea4d07a6a04f028362a91f2
3
+ metadata.gz: 2edd88411f92dbdbb1d06b334006e446d5b3e3fb165f3baae3745bd066cf9651
4
+ data.tar.gz: 437032f606bb6f77fee02e65706e615f8a52c0e05467bbe257f1796fcedd624c
5
5
  SHA512:
6
- metadata.gz: 522d80a40d4189fe483ad77f213f676afabbf6d27d834ebb84c6cf2c79f11060f11015e0b2fe92cf08e0fa5144244b94f7f36c785db43577722660e216b7039c
7
- data.tar.gz: 7d2e4905752d86fadd6ac8d780970c4e8abd622cdb3b93aa94503bc4f03b3c658bbc6901c110bcf1dc16e18610aa2f7e57bae061525eb879b1d2e43ba4a3fcb2
6
+ metadata.gz: 698398dc76ca4e3dd11e3c5dc6b078998f23895bd3d975b01e1329c08c8ff0835cb9691d0108f0f6e13aaa769b870b258ff5e1de1958321be4804ca99b30a0be
7
+ data.tar.gz: 2a1fdcc61d683a991d07f601a986c5bc04d40cdd7155a1833dc7dba46be014c23d36612c505531b2f2adfe08ed057d6a493cbf5df368318205ffaf88659a88fb
data/lib/bunny/channel.rb CHANGED
@@ -378,7 +378,7 @@ module Bunny
378
378
  # @see http://rubybunny.info/articles/exchanges.html Exchanges and Publishing guide
379
379
  # @api public
380
380
  def default_exchange
381
- Exchange.default(self)
381
+ @default_exchange ||= Exchange.default(self)
382
382
  end
383
383
 
384
384
  # Declares a headers exchange or looks it up in the cache of previously
@@ -396,7 +396,7 @@ module Bunny
396
396
  # @see http://rubybunny.info/articles/exchanges.html Exchanges and Publishing guide
397
397
  # @see http://rubybunny.info/articles/extensions.html RabbitMQ Extensions to AMQP 0.9.1 guide
398
398
  def exchange(name, opts = {})
399
- Exchange.new(self, opts.fetch(:type, :direct), name, opts)
399
+ find_exchange(name) || Exchange.new(self, opts.fetch(:type, :direct), name, opts)
400
400
  end
401
401
 
402
402
  # @endgroup
data/lib/bunny/session.rb CHANGED
@@ -128,6 +128,7 @@ module Bunny
128
128
  # @option connection_string_or_opts [Integer] :reset_recovery_attempts_after_reconnection (true) Should recovery attempt counter be reset after successful reconnection? When set to false, the attempt counter will last through the entire lifetime of the connection object.
129
129
  # @option connection_string_or_opts [Proc] :recovery_attempt_started (nil) Will be called before every connection recovery attempt
130
130
  # @option connection_string_or_opts [Proc] :recovery_completed (nil) Will be called after successful connection recovery
131
+ # @option connection_string_or_opts [Proc] :recovery_attempts_exhausted (nil) Will be called when the connection recovery failed after the specified amount of recovery attempts
131
132
  # @option connection_string_or_opts [Boolean] :recover_from_connection_close (true) Should this connection recover after receiving a server-sent connection.close (e.g. connection was force closed)?
132
133
  # @option connection_string_or_opts [Object] :session_error_handler (Thread.current) Object which responds to #raise that will act as a session error handler. Defaults to Thread.current, which will raise asynchronous exceptions in the thread that created the session.
133
134
  #
@@ -225,6 +226,7 @@ module Bunny
225
226
 
226
227
  @recovery_attempt_started = opts[:recovery_attempt_started]
227
228
  @recovery_completed = opts[:recovery_completed]
229
+ @recovery_attempts_exhausted = opts[:recovery_attempts_exhausted]
228
230
 
229
231
  @session_error_handler = opts.fetch(:session_error_handler, Thread.current)
230
232
 
@@ -553,6 +555,12 @@ module Bunny
553
555
  @recovery_completed = block
554
556
  end
555
557
 
558
+ # Defines a callable (e.g. a block) that will be called
559
+ # when the connection recovery failed after the specified
560
+ # numbers of recovery attempts.
561
+ def after_recovery_attempts_exhausted(&block)
562
+ @recovery_attempts_exhausted = block
563
+ end
556
564
 
557
565
  #
558
566
  # Implementation
@@ -809,6 +817,7 @@ module Bunny
809
817
  @transport.close
810
818
  self.close(false)
811
819
  @manually_closed = false
820
+ notify_of_recovery_attempts_exhausted
812
821
  end
813
822
  else
814
823
  raise e
@@ -859,6 +868,11 @@ module Bunny
859
868
  @recovery_completed.call if @recovery_completed
860
869
  end
861
870
 
871
+ # @private
872
+ def notify_of_recovery_attempts_exhausted
873
+ @recovery_attempts_exhausted.call if @recovery_attempts_exhausted
874
+ end
875
+
862
876
  # @private
863
877
  def instantiate_connection_level_exception(frame)
864
878
  case frame
data/lib/bunny/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Bunny
4
4
  # @return [String] Version of the library
5
- VERSION = "2.21.0"
5
+ VERSION = "2.22.0"
6
6
  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: 2.21.0
4
+ version: 2.22.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: 2023-06-08 00:00:00.000000000 Z
15
+ date: 2023-06-12 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: amq-protocol
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
120
  - !ruby/object:Gem::Version
121
121
  version: '0'
122
122
  requirements: []
123
- rubygems_version: 3.4.6
123
+ rubygems_version: 3.5.0.dev
124
124
  signing_key:
125
125
  specification_version: 4
126
126
  summary: Popular easy to use Ruby client for RabbitMQ