-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix #1978 Introduce retry builder and state-Function-based retry
This introduces a retry variant based on a `Function`, a bit like retryWhen, except the input is not merely a `Throwable` but a `RetrySignal`. This allows retry function to check if there was some success (onNext) since last retry attempt, in which case the current attempt can be interpreted as if this was the first ever error. This is especially useful for cases where exponential backoff delays should be reset, for long lived sequences that only see intermittent bursts of errors. The Function is actually provided through a `Supplier`, and one such supplier is the newly introduced `Retry.Builder`. The builder is more simple than the one in addons, but covers some good ground. It allows predicate on either exponential backoff strategy or simple retry strategy. In both cases one can also chose to consider `transientError(boolean)` (reset on onNext). For the simple case, this means that the remaining number of retries is reset in case of onNext. For the exponential case, this means retry delay is reset to minimum after an onNext. Old `retryWhen` decorates the user provided function to only look at the exception. We have only 1 builder, that switches from simple to backoff as soon as one of the backoff configuration methods are invoked. One cannot easily switch back. Factory methods help select the backoff strategy right away. The API is based on a `Supplier<Function>` so that it is not constrained on the provided `Retry.Builder`: anybody can easily write their own builder of advanced retry functions.
- Loading branch information
1 parent
64d0ea2
commit e964a16
Showing
9 changed files
with
834 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.