File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -184,11 +184,31 @@ func (c *Client) addRetryConditional(retryConditional RetryConditional) *Client
184
184
return c
185
185
}
186
186
187
+ // SetRetryMaxWaitTime sets the maximum delay before retrying a request.
187
188
func (c * Client ) SetRetryMaxWaitTime (max time.Duration ) * Client {
188
189
c .resty .SetRetryMaxWaitTime (max )
189
190
return c
190
191
}
191
192
193
+ // SetRetryWaitTime sets the default (minimum) delay before retrying a request.
194
+ func (c * Client ) SetRetryWaitTime (min time.Duration ) * Client {
195
+ c .resty .SetRetryWaitTime (min )
196
+ return c
197
+ }
198
+
199
+ // SetRetryAfter sets the callback function to be invoked with a failed request
200
+ // to determine wben it should be retried.
201
+ func (c * Client ) SetRetryAfter (callback RetryAfter ) * Client {
202
+ c .resty .SetRetryAfter (resty .RetryAfterFunc (callback ))
203
+ return c
204
+ }
205
+
206
+ // SetRetryCount sets the maximum retry attempts before aborting.
207
+ func (c * Client ) SetRetryCount (count int ) * Client {
208
+ c .resty .SetRetryCount (count )
209
+ return c
210
+ }
211
+
192
212
// SetPollDelay sets the number of milliseconds to wait between events or status polls.
193
213
// Affects all WaitFor* functions and retries.
194
214
func (c * Client ) SetPollDelay (delay time.Duration ) * Client {
Original file line number Diff line number Diff line change @@ -14,6 +14,9 @@ const retryAfterHeaderName = "Retry-After"
14
14
// type RetryConditional func(r *resty.Response) (shouldRetry bool)
15
15
type RetryConditional resty.RetryConditionFunc
16
16
17
+ // type RetryAfter func(c *resty.Client, r *resty.Response) (time.Duration, error)
18
+ type RetryAfter resty.RetryAfterFunc
19
+
17
20
// Configures resty to
18
21
// lock until enough time has passed to retry the request as determined by the Retry-After response header.
19
22
// If the Retry-After header is not set, we fall back to value of SetPollDelay.
You can’t perform that action at this time.
0 commit comments