MCPcopy Create free account
hub / github.com/imroc/req / SetRetryInterval

Method SetRetryInterval

request.go:1180–1183  ·  view source on GitHub ↗

SetRetryInterval sets the custom GetRetryIntervalFunc, you can use this to implement your own backoff retry algorithm. For example: req.SetRetryInterval(func(resp *req.Response, attempt int) time.Duration { sleep := 0.01 * math.Exp2(float64(attempt)) return time.Duration(math.Min(2, slee

(getRetryIntervalFunc GetRetryIntervalFunc)

Source from the content-addressed store, hash-verified

1178// return time.Duration(math.Min(2, sleep)) * time.Second
1179// })
1180func (r *Request) SetRetryInterval(getRetryIntervalFunc GetRetryIntervalFunc) *Request {
1181 r.getRetryOption().GetRetryInterval = getRetryIntervalFunc
1182 return r
1183}
1184
1185// SetRetryFixedInterval set retry to use a fixed interval.
1186func (r *Request) SetRetryFixedInterval(interval time.Duration) *Request {

Callers 2

TestRetryIntervalFunction · 0.80
SetRetryIntervalFunction · 0.80

Calls 1

getRetryOptionMethod · 0.95

Tested by 1

TestRetryIntervalFunction · 0.64