Skip to content

Commit

Permalink
Fix openssl error handling, #83
Browse files Browse the repository at this point in the history
  • Loading branch information
mperham committed Feb 14, 2024
1 parent e163c28 commit 88ee48c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/faktory/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ def initialize(url: uri_from_env || "tcp://localhost:7419", debug: false, timeou
@debug = debug
@location = URI(url)
@timeout = timeout
@errors = [SystemCallError, SocketError, TimeoutError]

if tls?
require "openssl"
@errors << OpenSSL::SSL::SSLError
end

open_socket(@timeout)
end
Expand Down Expand Up @@ -251,7 +257,6 @@ def tls?
# NB: aliased by faktory/testing
def open_socket(timeout = DEFAULT_TIMEOUT)
if tls?
require "openssl"
sock = TCPSocket.new(@location.hostname, @location.port)
sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_KEEPALIVE, true)

Expand Down Expand Up @@ -321,7 +326,7 @@ def transaction

begin
yield
rescue SystemCallError, SocketError, TimeoutError, OpenSSL::SSL::SSLError
rescue *@errors
if retryable
retryable = false

Expand Down

0 comments on commit 88ee48c

Please sign in to comment.