Skip to content

Commit

Permalink
fix: add debug logs for retry conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
Meallia committed Dec 6, 2022
1 parent 932e188 commit 6f183ef
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions restapi/api_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,16 @@ func (client *APIClient) doRequest(req *http.Request) (*http.Response, error) {
return resp, err
}
}
// retry
if client.debug {
log.Printf("api_client.go: Retryable error: %s\n", err)
}
} else { // HTTP response
if !((resp.StatusCode == http.StatusTooManyRequests) || (resp.StatusCode == 0) || (resp.StatusCode >= 500 && resp.StatusCode != http.StatusNotImplemented)) {
return resp, err
}
// retry
if client.debug {
log.Printf("api_client.go: Retryable HTTP code: %d\n", resp.StatusCode)
}
}
time.Sleep(time.Duration(5*(1+attempt) + rand.Intn(5)))
}
Expand Down

0 comments on commit 6f183ef

Please sign in to comment.