Class RetryWithDelayHandler
- java.lang.Object
-
- com.couchbase.client.java.util.retry.RetryWithDelayHandler
-
- All Implemented Interfaces:
rx.functions.Func1<Tuple2<Integer,Throwable>,rx.Observable<?>>,rx.functions.Function
@Committed @Public public class RetryWithDelayHandler extends Object implements rx.functions.Func1<Tuple2<Integer,Throwable>,rx.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.- Since:
- 2.1
- Author:
- Simon Baslé
- See Also:
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.
-
-
Field Summary
Fields Modifier and Type Field Description protected rx.functions.Action4<Integer,Throwable,Long,TimeUnit>doOnRetryprotected rx.functions.Func1<Throwable,Boolean>errorInterruptingPredicateprotected intmaxAttemptsprotected rx.ScheduleroptionalSchedulerprotected DelayretryDelay
-
Constructor Summary
Constructors Modifier Constructor Description RetryWithDelayHandler(int maxAttempts, Delay retryDelay)Construct aretry handlerthat will retry on all errors.RetryWithDelayHandler(int maxAttempts, Delay retryDelay, rx.functions.Func1<Throwable,Boolean> errorInterruptingPredicate, rx.functions.Action4<Integer,Throwable,Long,TimeUnit> doOnRetry)Construct aretry handlerthat will retry on most errors but will stop on specific errors.protectedRetryWithDelayHandler(int maxAttempts, Delay retryDelay, rx.functions.Func1<Throwable,Boolean> errorInterruptingPredicate, rx.functions.Action4<Integer,Throwable,Long,TimeUnit> doOnRetry, rx.Scheduler scheduler)Protected constructor that also allows to set aSchedulerfor the delay, especially useful for tests.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description rx.Observable<?>call(Tuple2<Integer,Throwable> attemptError)protected static StringmessageForMaxAttempts(long reachedAfterNRetries)
-
-
-
Constructor Detail
-
RetryWithDelayHandler
public RetryWithDelayHandler(int maxAttempts, Delay retryDelay)Construct aretry handlerthat will retry on all errors.- Parameters:
maxAttempts- the maximum number of retries before aCannotRetryExceptionis thrown. It will be capped at.Integer.MAX_VALUE- 1retryDelay- theDelayto apply between each retry (can grow, eg. by usingExponentialDelay).
-
RetryWithDelayHandler
public RetryWithDelayHandler(int maxAttempts, Delay retryDelay, rx.functions.Func1<Throwable,Boolean> errorInterruptingPredicate, rx.functions.Action4<Integer,Throwable,Long,TimeUnit> doOnRetry)Construct aretry handlerthat will retry on most errors but will stop on specific errors.- Parameters:
maxAttempts- the maximum number of retries before aCannotRetryExceptionis thrown. It will be capped at.Integer.MAX_VALUE- 1retryDelay- theDelayto apply between each retry (can grow, eg. by usingExponentialDelay).errorInterruptingPredicate- a predicate that determine if an error must stop the retry cycle (when true), in which case said error is cascaded down.
-
RetryWithDelayHandler
protected RetryWithDelayHandler(int maxAttempts, Delay retryDelay, rx.functions.Func1<Throwable,Boolean> errorInterruptingPredicate, rx.functions.Action4<Integer,Throwable,Long,TimeUnit> doOnRetry, rx.Scheduler scheduler)Protected constructor that also allows to set aSchedulerfor the delay, especially useful for tests.
-
-