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)
| 1178 | // return time.Duration(math.Min(2, sleep)) * time.Second |
| 1179 | // }) |
| 1180 | func (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. |
| 1186 | func (r *Request) SetRetryFixedInterval(interval time.Duration) *Request { |