@InterfaceStability.Experimental @InterfaceAudience.Public public class RetryWithDelayHandler extends Object implements Func1<com.couchbase.client.core.lang.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.
| Modifier and Type | Field and Description |
|---|---|
protected int |
maxAttempts |
protected Scheduler |
optionalScheduler |
protected com.couchbase.client.core.time.Delay |
retryDelay |
protected Func1<Throwable,Boolean> |
stoppingErrorFilter |
| Constructor and Description |
|---|
RetryWithDelayHandler(int maxAttempts,
com.couchbase.client.core.time.Delay retryDelay)
Construct a
retry handler that will retry on all errors. |
RetryWithDelayHandler(int maxAttempts,
com.couchbase.client.core.time.Delay retryDelay,
Func1<Throwable,Boolean> stoppingErrorFilter)
Construct a
retry handler that will retry on most errors but will stop on specific errors. |
RetryWithDelayHandler(int maxAttempts,
com.couchbase.client.core.time.Delay retryDelay,
Func1<Throwable,Boolean> stoppingErrorFilter,
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(com.couchbase.client.core.lang.Tuple2<Integer,Throwable> attemptError) |
protected static String |
messageForMaxAttempts(long reachedAfterNRetries) |
protected final int maxAttempts
protected final com.couchbase.client.core.time.Delay retryDelay
protected final Scheduler optionalScheduler
public RetryWithDelayHandler(int maxAttempts,
com.couchbase.client.core.time.Delay retryDelay)
Construct a retry handler that will retry on all errors.
maxAttempts - the maximum number of retries before a CannotRetryException is thrown.retryDelay - the Delay to apply between each retry (can grow, eg. by using ExponentialDelay).public RetryWithDelayHandler(int maxAttempts,
com.couchbase.client.core.time.Delay retryDelay,
Func1<Throwable,Boolean> stoppingErrorFilter)
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.retryDelay - the Delay to apply between each retry (can grow, eg. by using ExponentialDelay).stoppingErrorFilter - a predicate that determine if an error must stop the retry cycle (when true), in which case said error is cascaded down.protected static String messageForMaxAttempts(long reachedAfterNRetries)
public Observable<?> call(com.couchbase.client.core.lang.Tuple2<Integer,Throwable> attemptError)
call in interface Func1<com.couchbase.client.core.lang.Tuple2<Integer,Throwable>,Observable<?>>Copyright © 2014 Couchbase, Inc.