@InterfaceStability.Experimental @InterfaceAudience.Public public class RetryWithDelayHandler extends Object implements Func1<Tuple2<Integer,Throwable>,Observable<?>>
A class that allows to produce a “retry” delay depending on the number of retry attempts. The number of retries is bounded by a maximum number of attempts.
how to wrap an Observable with this behavior
,
how to chain this behavior into an Observable's retryWhen operation.
,
how to construct a RetryWhenFunction in a fluent manner.
Modifier and Type | Field and Description |
---|---|
protected Action4<Integer,Throwable,Long,TimeUnit> |
doOnRetry |
protected Func1<Throwable,Boolean> |
errorInterruptingPredicate |
protected int |
maxAttempts |
protected Scheduler |
optionalScheduler |
protected Delay |
retryDelay |
Modifier | Constructor and Description |
---|---|
|
RetryWithDelayHandler(int maxAttempts,
Delay retryDelay)
Construct a
retry handler that will retry on all errors. |
|
RetryWithDelayHandler(int maxAttempts,
Delay retryDelay,
Func1<Throwable,Boolean> errorInterruptingPredicate,
Action4<Integer,Throwable,Long,TimeUnit> doOnRetry)
Construct a
retry handler that will retry on most errors but will stop on specific errors. |
protected |
RetryWithDelayHandler(int maxAttempts,
Delay retryDelay,
Func1<Throwable,Boolean> errorInterruptingPredicate,
Action4<Integer,Throwable,Long,TimeUnit> doOnRetry,
Scheduler scheduler)
Protected constructor that also allows to set a
Scheduler for the delay, especially useful for tests. |
Modifier and Type | Method and Description |
---|---|
Observable<?> |
call(Tuple2<Integer,Throwable> attemptError) |
protected static String |
messageForMaxAttempts(long reachedAfterNRetries) |
protected final int maxAttempts
protected final Delay retryDelay
protected final Scheduler optionalScheduler
public RetryWithDelayHandler(int maxAttempts, Delay retryDelay)
Construct a retry handler
that will retry on all errors.
maxAttempts
- the maximum number of retries before a CannotRetryException
is thrown. It will be capped at Integer.MAX_VALUE
- 1
.retryDelay
- the Delay
to apply between each retry (can grow, eg. by using ExponentialDelay
).public RetryWithDelayHandler(int maxAttempts, Delay retryDelay, Func1<Throwable,Boolean> errorInterruptingPredicate, Action4<Integer,Throwable,Long,TimeUnit> doOnRetry)
Construct a retry handler
that will retry on most errors but will stop on specific errors.
maxAttempts
- the maximum number of retries before a CannotRetryException
is thrown. It will be capped at Integer.MAX_VALUE
- 1
.retryDelay
- the Delay
to apply between each retry (can grow, eg. by using ExponentialDelay
).errorInterruptingPredicate
- a predicate that determine if an error must stop the retry cycle (when true), in which case said error is cascaded down.protected RetryWithDelayHandler(int maxAttempts, Delay retryDelay, Func1<Throwable,Boolean> errorInterruptingPredicate, Action4<Integer,Throwable,Long,TimeUnit> doOnRetry, Scheduler scheduler)
Protected constructor that also allows to set a Scheduler
for the delay, especially useful for tests.
Copyright © 2015 Couchbase, Inc.