Add Ability to RetryPolicy to Ignore a Failure
numeralnathan opened this issue · 7 comments
Please add to RetryPolicy a mechanism to essentially ignore a failure. For example, if an HTTP response code is 429 Too Many Requests, then I would like to delay and then try again but not have it count against the number of attempts.
Wouldn't that just be two nested RetryPolicy instances? The inner one would only retry on 429, treating anything else (actual success or non-429 error) as "success", and the outer one would be your original retry handler. The failure count on the outer would be the one you'd use. It wouldn't count the 429-triggered retries.
@numeralnathan What's the significance of not incrementing the number of attempts, for your use case?
@Tembrel This is a great idea! The inner RetryPolicy
could have withMaxRetries(Integer.MAX_VALUE)
.
@jhalterman Are you saying that on failure, I could increment the policy's attempt count?
Sure, though wouldn't you want some practical limit on the number of retries? After the billionth 429, you might want to consider packing it in. 😀
@numeralnathan No, you won't be able to influence that, I was just curious about your use case, and why having the attempt count not increment sometimes is important.
@Tembrel Yeah, typically one would give up. In this case, this is the only thing for the program to do. So, waiting and trying again is appropriate for an infinite number of calls. On a subsequent request, the server will delay processing the request and finally respond with the data.