Skip to content

Commit

Permalink
execute retry hook in reverse order
Browse files Browse the repository at this point in the history
  • Loading branch information
imroc committed Aug 4, 2023
1 parent 6bfbd55 commit 9059ed0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions request.go
Original file line number Diff line number Diff line change
Expand Up @@ -677,8 +677,10 @@ func (r *Request) do() (resp *Response, err error) {

// need retry, attempt to retry
r.RetryAttempt++
for _, hook := range r.retryOption.RetryHooks { // run retry hooks
hook(resp, err)
if l := len(r.retryOption.RetryHooks); l > 0 {
for i := l - 1; i >= 0; i-- { // run retry hooks in reverse order
r.retryOption.RetryHooks[i](resp, err)
}
}
time.Sleep(r.retryOption.GetRetryInterval(resp, r.RetryAttempt))

Expand Down

0 comments on commit 9059ed0

Please sign in to comment.