@InterfaceStability.Experimental @InterfaceAudience.Public public class Retry extends Object
Utility methods to deal with retrying Observables.
| Modifier and Type | Field and Description |
|---|---|
static Delay |
DEFAULT_DELAY |
| Constructor and Description |
|---|
Retry() |
| Modifier and Type | Method and Description |
|---|---|
protected static Observable<Tuple2<Integer,Throwable>> |
errorsWithAttempts(Observable<? extends Throwable> errors,
int expectedAttempts)
Internal utility method to combine errors in an observable with their attempt number.
|
static <T> Observable<T> |
wrapForRetry(Observable<T> source,
int maxAttempts)
Wrap an
Observable so that it will retry on all errors for a maximum number of times. |
static <T> Observable<T> |
wrapForRetry(Observable<T> source,
int maxAttempts,
Delay retryDelay)
Wrap an
Observable so that it will retry on all errors. |
static <T> Observable<T> |
wrapForRetry(Observable<T> source,
RetryWithDelayHandler handler)
Wrap an
Observable so that it will retry on some errors. |
public static final Delay DEFAULT_DELAY
public static <T> Observable<T> wrapForRetry(Observable<T> source, int maxAttempts)
Wrap an Observable so that it will retry on all errors for a maximum number of times. The retry is almost immediate (1ms delay).
source - the Observable to wrap.maxAttempts - the maximum number of times to attempt a retry. It will be capped at Integer.MAX_VALUE - 1.T - the type of items emitted by the source Observable.public static <T> Observable<T> wrapForRetry(Observable<T> source, int maxAttempts, Delay retryDelay)
Wrap an Observable so that it will retry on all errors. The retry will occur for a maximum number of attempts and with a provided Delay between each attempt.
source - the Observable to wrap.maxAttempts - the maximum number of times to attempt a retry. It will be capped at Integer.MAX_VALUE - 1.retryDelay - the Delay between each attempt.T - the type of items emitted by the source Observable.public static <T> Observable<T> wrapForRetry(Observable<T> source, RetryWithDelayHandler handler)
Wrap an Observable so that it will retry on some errors. The retry will occur for a maximum number of attempts and with a provided Delay between each attempt represented by the RetryWithDelayHandler, which can also filter on errors and stop the retry cycle for certain type of errors.
source - the Observable to wrap.handler - the RetryWithDelayHandler, describes maximum number of attempts, delay and fatal errors.T - the type of items emitted by the source Observable.protected static Observable<Tuple2<Integer,Throwable>> errorsWithAttempts(Observable<? extends Throwable> errors, int expectedAttempts)
Internal utility method to combine errors in an observable with their attempt number.
errors - the errors.expectedAttempts - the maximum of combinations to make (for retry, should be the maximum number of authorized retries + 1).Tuple2.Copyright © 2015 Couchbase, Inc.