resty
resty copied to clipboard
SetRetryCount allows negative values that Backoff doesn't properly handle
SetRetryCount allows values less than zero, but the Backoff implementation assumes opts.maxRetries is zero or greater. The result is that Backoff doesn't actually make a request but also doesn't return an error.
Two options for a solution:
- Convert negative values to zero in
SetRetryCount. - Convert a negative value into
math.MaxInt64(retry forever) inSetRetryCount.
In either case, Backoff should be updated to return an error if opts.maxRetries is less than zero.
Related to #392
@yjhmelody commented here that option 2 (retry forever) is preferred.
I tend to agree. Normally, a -1 in this scenario means "no limit."
@moorereason @yjhmelody Just wondering, the forever retry option is good or bad for the client library since it will result in DoS behavior on targeted application/service.
Prevent -1 usage with error message