diff --git a/client.go b/client.go index 9342df4ae..d7edc97f3 100644 --- a/client.go +++ b/client.go @@ -184,11 +184,31 @@ func (c *Client) addRetryConditional(retryConditional RetryConditional) *Client return c } +// SetRetryMaxWaitTime sets the maximum delay before retrying a request. func (c *Client) SetRetryMaxWaitTime(max time.Duration) *Client { c.resty.SetRetryMaxWaitTime(max) return c } +// SetRetryWaitTime sets the default (minimum) delay before retrying a request. +func (c *Client) SetRetryWaitTime(min time.Duration) *Client { + c.resty.SetRetryWaitTime(min) + return c +} + +// SetRetryAfter sets the callback function to be invoked with a failed request +// to determine wben it should be retried. +func (c *Client) SetRetryAfter(callback RetryAfter) *Client { + c.resty.SetRetryAfter(resty.RetryAfterFunc(callback)) + return c +} + +// SetRetryCount sets the maximum retry attempts before aborting. +func (c *Client) SetRetryCount(count int) *Client { + c.resty.SetRetryCount(count) + return c +} + // SetPollDelay sets the number of milliseconds to wait between events or status polls. // Affects all WaitFor* functions and retries. func (c *Client) SetPollDelay(delay time.Duration) *Client { diff --git a/retries.go b/retries.go index 6f678104f..2a48bb818 100644 --- a/retries.go +++ b/retries.go @@ -14,6 +14,9 @@ const retryAfterHeaderName = "Retry-After" // type RetryConditional func(r *resty.Response) (shouldRetry bool) type RetryConditional resty.RetryConditionFunc +// type RetryAfter func(c *resty.Client, r *resty.Response) (time.Duration, error) +type RetryAfter resty.RetryAfterFunc + // Configures resty to // lock until enough time has passed to retry the request as determined by the Retry-After response header. // If the Retry-After header is not set, we fall back to value of SetPollDelay.