Modifier and Type | Method and Description |
---|---|
Retryer<V> |
build()
Builds the retryer.
|
static <V> RetryerBuilder<V> |
newBuilder()
Constructs a new builder
|
RetryerBuilder<V> |
retryIfException()
Configures the retryer to retry if an exception (i.e.
|
RetryerBuilder<V> |
retryIfException(com.google.common.base.Predicate<java.lang.Throwable> exceptionPredicate)
Configures the retryer to retry if an exception satisfying the given predicate is
thrown by the call.
|
RetryerBuilder<V> |
retryIfExceptionOfType(java.lang.Class<? extends java.lang.Throwable> exceptionClass)
Configures the retryer to retry if an exception of the given class (or subclass of the given class) is
thrown by the call.
|
RetryerBuilder<V> |
retryIfResult(com.google.common.base.Predicate<V> resultPredicate)
Configures the retryer to retry if the result satisfies the given predicate.
|
RetryerBuilder<V> |
retryIfRuntimeException()
Configures the retryer to retry if a runtime exception (i.e.
|
RetryerBuilder<V> |
withAttemptTimeLimiter(AttemptTimeLimiter<V> attemptTimeLimiter)
Configures the retryer to limit the duration of any particular attempt by the given duration.
|
RetryerBuilder<V> |
withStopStrategy(StopStrategy stopStrategy)
Sets the stop strategy used to decide when to stop retrying.
|
RetryerBuilder<V> |
withWaitStrategy(WaitStrategy waitStrategy)
Sets the wait strategy used to decide how long to sleep between failed attempts.
|
public static <V> RetryerBuilder<V> newBuilder()
V
- result of a Retryer
's call, the type of the call return valuepublic RetryerBuilder<V> withWaitStrategy(@Nonnull WaitStrategy waitStrategy) throws java.lang.IllegalStateException
waitStrategy
- the strategy used to sleep between failed attemptsthis
java.lang.IllegalStateException
- if a wait strategy has already been set.public RetryerBuilder<V> withStopStrategy(@Nonnull StopStrategy stopStrategy) throws java.lang.IllegalStateException
stopStrategy
- the strategy used to decide when to stop retryingthis
java.lang.IllegalStateException
- if a stop strategy has already been set.public RetryerBuilder<V> withAttemptTimeLimiter(@Nonnull AttemptTimeLimiter<V> attemptTimeLimiter)
attemptTimeLimiter
- to apply to each attemptthis
public RetryerBuilder<V> retryIfException()
Exception
or subclass
of Exception
) is thrown by the call.this
public RetryerBuilder<V> retryIfRuntimeException()
RuntimeException
or subclass
of RuntimeException
) is thrown by the call.this
public RetryerBuilder<V> retryIfExceptionOfType(@Nonnull java.lang.Class<? extends java.lang.Throwable> exceptionClass)
exceptionClass
- the type of the exception which should cause the retryer to retrythis
public RetryerBuilder<V> retryIfException(@Nonnull com.google.common.base.Predicate<java.lang.Throwable> exceptionPredicate)
exceptionPredicate
- the predicate which causes a retry if satisfiedthis
public RetryerBuilder<V> retryIfResult(@Nonnull com.google.common.base.Predicate<V> resultPredicate)
resultPredicate
- a predicate applied to the result, and which causes the retryer
to retry if the predicate is satisfiedthis