Skip to content

Commit

Permalink
Merge pull request #336 from rollbar/pawel/add_errors_to_retry
Browse files Browse the repository at this point in the history
added some common http error codes to the retry logic
  • Loading branch information
pawelsz-rb authored Dec 13, 2022
2 parents 9f11063 + 291e914 commit ce7ec07
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,17 @@ func NewClient(baseURL, token string) *RollbarAPIClient {
// Set retry count to 4 (try 5 times before it fails)
SetRetryCount(4).
SetRetryWaitTime(8 * time.Second).
SetRetryMaxWaitTime(50 * time.Second)
SetRetryMaxWaitTime(50 * time.Second).
AddRetryCondition(
func(r *resty.Response, err error) bool {
if err != nil { // network error
return true
}
return r.StatusCode() == http.StatusNotFound ||
r.StatusCode() == http.StatusTooManyRequests ||
r.StatusCode() == http.StatusInternalServerError ||
r.StatusCode() == http.StatusBadGateway
})
// Authentication
if token != "" {
r = r.SetHeaders(map[string]string{
Expand Down

0 comments on commit ce7ec07

Please sign in to comment.