Skip to content

Commit

Permalink
Retry on all connect errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nghia Tran committed Sep 12, 2019
1 parent 54d5ef4 commit 2492232
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions pkg/network/transports.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,13 @@ func dialBackOffHelper(ctx context.Context, network, address string, steps int,
for i := 0; i < steps; i++ {
c, err := dialer.DialContext(ctx, network, address)
if err != nil {
if err, ok := err.(net.Error); ok && err.Temporary() {
if i == steps-1 {
break
}
to *= factor
dialer.Timeout = time.Duration(to)
time.Sleep(wait.Jitter(sleep, 1.0)) // Sleep with jitter.
continue
if i == steps-1 {
break
}
return nil, err
to *= factor
dialer.Timeout = time.Duration(to)
time.Sleep(wait.Jitter(sleep, 1.0)) // Sleep with jitter.
continue
}
return c, err
}
Expand Down

0 comments on commit 2492232

Please sign in to comment.