Skip to content

Commit

Permalink
Dial without timeout if zero value is passed
Browse files Browse the repository at this point in the history
  • Loading branch information
mostafa committed Nov 17, 2023
1 parent 09bf6da commit 1b53710
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion network/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,15 @@ func NewClient(ctx context.Context, clientConfig *config.Client, logger zerolog.
}

// Create a new connection.
conn, origErr := net.DialTimeout(client.Network, client.Address, client.DialTimeout)
var (
conn net.Conn
origErr error
)
if client.DialTimeout == 0 {
conn, origErr = net.Dial(client.Network, client.Address)
} else {
conn, origErr = net.DialTimeout(client.Network, client.Address, client.DialTimeout)
}
if origErr != nil {
err := gerr.ErrClientConnectionFailed.Wrap(origErr)
logger.Error().Err(err).Msg("Failed to create a new connection")
Expand Down

0 comments on commit 1b53710

Please sign in to comment.