Skip to content

Commit

Permalink
patch on prior commit: test os.SyscallError first
Browse files Browse the repository at this point in the history
  • Loading branch information
twmb committed Jun 3, 2021
1 parent 2778ffc commit 5231902
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions pkg/kgo/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,18 @@ func isRetriableBrokerErr(err error) bool {
// appears as a hard failure can actually be retried. For example, a
// failed dial can be retried, maybe the resolver temporarily had a
// problem.
var tempErr interface{ Temporary() bool }
if errors.As(err, &tempErr) {
return tempErr.Temporary()
}
//
// We favor testing os.SyscallError first, because net.OpError _always_
// implements Temporary, so if we test that first, it'll return false
// in many cases when we want to return true from os.SyscallError.
var se *os.SyscallError
if errors.As(err, &se) {
return true
}
var tempErr interface{ Temporary() bool }
if errors.As(err, &tempErr) {
return tempErr.Temporary()
}
switch err {
case errChosenBrokerDead,
errCorrelationIDMismatch:
Expand Down

0 comments on commit 5231902

Please sign in to comment.