bunny 2.20.2 → 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: 46774013196be7a46ad133b7cf5af2fc4a6b2da1dc09c18542833cb1c9558298
4
- data.tar.gz: 0626e219bd998dcf20f34b050300ef03f1c8a0464936fb7fee4796bec840d463
3
+ metadata.gz: a51dd17b606b2363463849ba249e8bdff82f263237304def85c72d804a72cf9f
4
+ data.tar.gz: fc7754eb6f23de9759b515f9c98800ff24ecc0b1dea4d07a6a04f028362a91f2
5
5
  SHA512:
6
- metadata.gz: c3de342e840d6f79326cd8ba4711e723bfd35279f7a3299523bdef8df16478e6a6715b311534de11f2abe220ca1e7be0654b21d7a4a0c1529e849245c6d49593
7
- data.tar.gz: 3b738e7ce55f867da133175909afdde7f3167caa5598cdc6274dfd584263d13b55494b6dc2df674b0ed0955d6bf14413f750f2a245f76293a7037d6ffd93a726
6
+ metadata.gz: 522d80a40d4189fe483ad77f213f676afabbf6d27d834ebb84c6cf2c79f11060f11015e0b2fe92cf08e0fa5144244b94f7f36c785db43577722660e216b7039c
7
+ data.tar.gz: 7d2e4905752d86fadd6ac8d780970c4e8abd622cdb3b93aa94503bc4f03b3c658bbc6901c110bcf1dc16e18610aa2f7e57bae061525eb879b1d2e43ba4a3fcb2
data/README.md CHANGED
@@ -50,6 +50,11 @@ Modern Bunny versions support
50
50
  * CRuby 2.6 through 3.1 (inclusive)
51
51
  * [TruffleRuby](https://www.graalvm.org/ruby/)
52
52
 
53
+ For environments that use TLS, Bunny expects Ruby installations to use a recent enough OpenSSL version that
54
+ **includes support for TLS 1.3**.
55
+
56
+ ### JRuby
57
+
53
58
  Bunny works sufficiently well on JRuby but there are known
54
59
  JRuby bugs in versions prior to JRuby 9000 that cause high CPU burn. JRuby users should
55
60
  use [March Hare](http://rubymarchhare.info).
@@ -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
@@ -31,16 +31,23 @@ module Bunny
31
31
  TLSv1: OpenSSL::SSL::TLS1_VERSION,
32
32
  TLSv1_1: OpenSSL::SSL::TLS1_1_VERSION,
33
33
  TLSv1_2: OpenSSL::SSL::TLS1_2_VERSION,
34
- TLSv1_3: OpenSSL::SSL::TLS1_3_VERSION,
35
34
  "1.0": OpenSSL::SSL::TLS1_VERSION,
36
35
  "1.1": OpenSSL::SSL::TLS1_1_VERSION,
37
36
  "1.2": OpenSSL::SSL::TLS1_2_VERSION,
38
- "1.3": OpenSSL::SSL::TLS1_3_VERSION,
39
37
  OpenSSL::SSL::TLS1_VERSION => OpenSSL::SSL::TLS1_VERSION,
40
38
  OpenSSL::SSL::TLS1_1_VERSION => OpenSSL::SSL::TLS1_1_VERSION,
41
- OpenSSL::SSL::TLS1_2_VERSION => OpenSSL::SSL::TLS1_2_VERSION,
42
- OpenSSL::SSL::TLS1_3_VERSION => OpenSSL::SSL::TLS1_3_VERSION
43
- }.freeze
39
+ OpenSSL::SSL::TLS1_2_VERSION => OpenSSL::SSL::TLS1_2_VERSION
40
+ }
41
+
42
+ # older OpenSSL versions won't support for TLS 1.3 and won't
43
+ # have this constant defined.
44
+ if defined?(OpenSSL::SSL::TLS1_3_VERSION)
45
+ TLS_VERSION_ALIASES["1.3"] = OpenSSL::SSL::TLS1_3_VERSION
46
+ TLS_VERSION_ALIASES[:TLSv1_3] = OpenSSL::SSL::TLS1_3_VERSION
47
+ TLS_VERSION_ALIASES[OpenSSL::SSL::TLS1_3_VERSION] = OpenSSL::SSL::TLS1_3_VERSION
48
+ end
49
+
50
+ TLS_VERSION_ALIASES.freeze
44
51
 
45
52
  attr_reader :session, :host, :port, :socket, :connect_timeout, :read_timeout, :write_timeout, :disconnect_timeout
46
53
  attr_reader :tls_context, :verify_peer, :tls_ca_certificates, :tls_certificate_path, :tls_key_path
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.2"
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.2
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-12 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