Skip to content

Commit

Permalink
Add retry in 502,503 and 520
Browse files Browse the repository at this point in the history
  • Loading branch information
dianibar committed May 21, 2024
1 parent 69dc4a8 commit ba62018
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions internal/provider/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,14 @@ func (c *ClientTest) doRequest(req *http.Request) ([]byte, error) {
log.Println(errRetry)
return fmt.Errorf("no response")
}
if res.StatusCode == http.StatusTooManyRequests {
return fmt.Errorf("rate limit exceeded")
if res.StatusCode == http.StatusTooManyRequests ||
res.StatusCode == http.StatusGatewayTimeout{
return fmt.Errorf(http.StatusText(res.StatusCode))
}
if res.StatusCode == 520 {
return fmt.Errorf("Cloudflare 520 Error")
}

err = errRetry
return nil
}
Expand Down

0 comments on commit ba62018

Please sign in to comment.