bunny 2.20.3 → 2.21.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0638b435d0f724c5b9566797df9ba50e94144f0bb82f60b01e5d794bce868512'
4
- data.tar.gz: c278e7122a90653738ff68b845509873ed0e7ca7b5759e0a33a7157725bcf650
3
+ metadata.gz: a51dd17b606b2363463849ba249e8bdff82f263237304def85c72d804a72cf9f
4
+ data.tar.gz: fc7754eb6f23de9759b515f9c98800ff24ecc0b1dea4d07a6a04f028362a91f2
5
5
  SHA512:
6
- metadata.gz: 44e1c56c0500d2e375a22e6349401e25d9e1c8f9e553b91df0ed4ac07ee80167cd50e28f6191e549961a31c7795e07a740949b72c971178b2f35060a221cc312
7
- data.tar.gz: c0cbd8f1d0d6b6973f6ba6e3cc6140dbaa6843fe18cb00372e5b3a01bbdad5f1c265867b8314937ed711671266fb14fb281bbf739b2510a91fad4404b6ba4042
6
+ metadata.gz: 522d80a40d4189fe483ad77f213f676afabbf6d27d834ebb84c6cf2c79f11060f11015e0b2fe92cf08e0fa5144244b94f7f36c785db43577722660e216b7039c
7
+ data.tar.gz: 7d2e4905752d86fadd6ac8d780970c4e8abd622cdb3b93aa94503bc4f03b3c658bbc6901c110bcf1dc16e18610aa2f7e57bae061525eb879b1d2e43ba4a3fcb2
@@ -70,7 +70,7 @@ module Bunny
70
70
  return if !(wait_for_workers && @shutdown_timeout && was_running)
71
71
 
72
72
  @shutdown_mutex.synchronize do
73
- @shutdown_conditional.wait(@shutdown_mutex, @shutdown_timeout)
73
+ @shutdown_conditional.wait(@shutdown_mutex, @shutdown_timeout) if busy?
74
74
  end
75
75
  end
76
76
 
data/lib/bunny/session.rb CHANGED
@@ -71,6 +71,7 @@ module Bunny
71
71
  # Default reconnection interval for TCP connection failures
72
72
  DEFAULT_NETWORK_RECOVERY_INTERVAL = 5.0
73
73
 
74
+ DEFAULT_RECOVERABLE_EXCEPTIONS = [StandardError, TCPConnectionFailedForAllHosts, TCPConnectionFailed, AMQ::Protocol::EmptyResponseError, SystemCallError, Timeout::Error, Bunny::ConnectionLevelException, Bunny::ConnectionClosedError]
74
75
 
75
76
  #
76
77
  # API
@@ -91,6 +92,7 @@ module Bunny
91
92
  attr_reader :network_recovery_interval
92
93
  attr_reader :connection_name
93
94
  attr_accessor :socket_configurator
95
+ attr_accessor :recoverable_exceptions
94
96
 
95
97
  # @param [String, Hash] connection_string_or_opts Connection string or a hash of connection options
96
98
  # @param [Hash] optz Extra options not related to connection
@@ -226,6 +228,8 @@ module Bunny
226
228
 
227
229
  @session_error_handler = opts.fetch(:session_error_handler, Thread.current)
228
230
 
231
+ @recoverable_exceptions = DEFAULT_RECOVERABLE_EXCEPTIONS.dup
232
+
229
233
  self.reset_continuations
230
234
  self.initialize_transport
231
235
 
@@ -747,9 +751,7 @@ module Bunny
747
751
 
748
752
  # @private
749
753
  def recoverable_network_failure?(exception)
750
- # No reasonably smart strategy was suggested in a few years.
751
- # So just recover unconditionally. MK.
752
- true
754
+ @recoverable_exceptions.any? {|x| exception.kind_of? x}
753
755
  end
754
756
 
755
757
  # @private
@@ -794,19 +796,22 @@ module Bunny
794
796
  rescue HostListDepleted
795
797
  reset_address_index
796
798
  retry
797
- rescue TCPConnectionFailedForAllHosts, TCPConnectionFailed, AMQ::Protocol::EmptyResponseError, SystemCallError, Timeout::Error => e
798
- @logger.warn "TCP connection failed, reconnecting in #{@network_recovery_interval} seconds"
799
- if should_retry_recovery?
800
- decrement_recovery_attemp_counter!
801
- if recoverable_network_failure?(e)
799
+ rescue => e
800
+ if recoverable_network_failure?(e)
801
+ @logger.warn "TCP connection failed"
802
+ if should_retry_recovery?
803
+ @logger.warn "Reconnecting in #{@network_recovery_interval} seconds"
804
+ decrement_recovery_attemp_counter!
802
805
  announce_network_failure_recovery
803
806
  retry
807
+ else
808
+ @logger.error "Ran out of recovery attempts (limit set to #{@max_recovery_attempts}), giving up"
809
+ @transport.close
810
+ self.close(false)
811
+ @manually_closed = false
804
812
  end
805
813
  else
806
- @logger.error "Ran out of recovery attempts (limit set to #{@max_recovery_attempts}), giving up"
807
- @transport.close
808
- self.close(false)
809
- @manually_closed = false
814
+ raise e
810
815
  end
811
816
  end
812
817
 
@@ -1356,7 +1361,7 @@ module Bunny
1356
1361
  host_from_address(address),
1357
1362
  port_from_address(address),
1358
1363
  @opts.merge(:session_error_handler => @session_error_handler)
1359
- )
1364
+ )
1360
1365
 
1361
1366
  # Reset the cached progname for the logger only when no logger was provided
1362
1367
  @default_logger.progname = self.to_s
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.20.3"
5
+ VERSION = "2.21.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.20.3
4
+ version: 2.21.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-01-26 00:00:00.000000000 Z
15
+ date: 2023-06-08 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.1.4
123
+ rubygems_version: 3.4.6
124
124
  signing_key:
125
125
  specification_version: 4
126
126
  summary: Popular easy to use Ruby client for RabbitMQ