Skip to content

Commit

Permalink
Merge pull request #174 from Charliekenney23/feat/retry-on-408
Browse files Browse the repository at this point in the history
add retry condition for 408s
  • Loading branch information
0xch4z authored Jan 8, 2021
2 parents 897602d + da8be28 commit f260595
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ func (c *Client) SetRetries() *Client {
addRetryConditional(linodeBusyRetryCondition).
addRetryConditional(tooManyRequestsRetryCondition).
addRetryConditional(serviceUnavailableRetryCondition).
addRetryConditional(requestTimeoutRetryCondition).
SetRetryMaxWaitTime(APIRetryMaxWaitTime)
configureRetries(c)
return c
Expand Down
4 changes: 4 additions & 0 deletions retries.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ func serviceUnavailableRetryCondition(r *resty.Response, _ error) bool {
return r.StatusCode() == http.StatusServiceUnavailable
}

func requestTimeoutRetryCondition(r *resty.Response, _ error) bool {
return r.StatusCode() == http.StatusRequestTimeout
}

func respectRetryAfter(client *resty.Client, resp *resty.Response) (time.Duration, error) {
retryAfterStr := resp.Header().Get(retryAfterHeaderName)
if retryAfterStr == "" {
Expand Down

0 comments on commit f260595

Please sign in to comment.