Skip to content

Commit

Permalink
Copy new Backoffer for each request
Browse files Browse the repository at this point in the history
Signed-off-by: JmPotato <ghzpotato@gmail.com>
  • Loading branch information
JmPotato committed Jan 9, 2024
1 parent f18de09 commit 3b3b3e0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions client/http/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,13 @@ func (ci *clientInner) requestWithRetry(
if reqInfo.bo == nil {
return execFunc()
}
// Copy a new backoffer for each request.
bo := *reqInfo.bo
// Backoffer also needs to check the status code to determine whether to retry.
reqInfo.bo.SetRetryableChecker(func(err error) bool {
bo.SetRetryableChecker(func(err error) bool {
return err != nil && !noNeedRetry(statusCode)
})
return reqInfo.bo.Exec(ctx, execFunc)
return bo.Exec(ctx, execFunc)
}

func noNeedRetry(statusCode int) bool {
Expand Down

0 comments on commit 3b3b3e0

Please sign in to comment.