T
- the type to be returned by RetryWithRecovery.execute()
.@API(status=INTERNAL)
public class RetryWithRecoveryBuilder<T>
extends java.lang.Object
RetryWithRecovery
.Constructor and Description |
---|
RetryWithRecoveryBuilder()
Default constructor which ignores no exception
and retries exceptions fulfilling
isNetworkOrMinorError(java.lang.Throwable) . |
Modifier and Type | Method and Description |
---|---|
RetryWithRecoveryBuilder<T> |
basePath(java.lang.String address)
Sets the address and returns the modified builder.
|
RetryWithRecovery<T> |
build()
Builds a
RetryWithRecovery based on provided fields. |
RetryWithRecoveryBuilder<T> |
clearRecoveryStrategies()
Removes all the recovery strategies from the builder instance.
|
static <T> RetryWithRecoveryBuilder<T> |
copyWithoutRecoveryStrategies(RetryWithRecoveryBuilder<?> from) |
static <T> RetryWithRecoveryBuilder<T> |
from(RetryWithRecoveryBuilder<?> from)
Copies all fields of an existing builder except the
supplier . |
RetryWithRecoveryBuilder<T> |
ignoreException(java.util.function.Predicate<com.symphony.bdk.http.api.ApiException> ignoreException)
Sets the condition on which we should ignore an
ApiException thrown by the supplier
and return null in RetryWithRecovery.execute() . |
static boolean |
isNetworkOrMinorError(java.lang.Throwable t)
Checks if a throwable is a network issue or a
ApiException minor error. |
static boolean |
isNetworkOrMinorErrorOrClientError(java.lang.Throwable t)
Checks if a throwable is a network issue or a
ApiException minor error or client error. |
RetryWithRecoveryBuilder<T> |
name(java.lang.String name)
Sets the name and returns the modified builder.
|
<E extends java.lang.Exception> |
recoveryStrategy(java.lang.Class<? extends E> exceptionType,
ConsumerWithThrowable recovery)
Sets one recovery strategy which consists of a specific
Exception type
and of a corresponding recovery function to be executed when exception is of the given provided type. |
RetryWithRecoveryBuilder<T> |
recoveryStrategy(java.util.function.Predicate<com.symphony.bdk.http.api.ApiException> condition,
ConsumerWithThrowable recovery)
Sets one recovery strategy which consists of a predicate on a thrown
ApiException
and of a corresponding recovery function to be executed when condition is met. |
RetryWithRecoveryBuilder<T> |
retryConfig(BdkRetryConfig retryConfig)
Sets the retry configuration and returns the modified builder.
|
RetryWithRecoveryBuilder<T> |
retryOnException(java.util.function.Predicate<java.lang.Throwable> retryOnExceptionPredicate)
Sets the conditions on which we should retry the call to the provided
supplier . |
RetryWithRecoveryBuilder<T> |
supplier(SupplierWithApiException<T> supplier)
Sets the retry configuration and returns the modified builder.
|
public RetryWithRecoveryBuilder()
isNetworkOrMinorError(java.lang.Throwable)
.public static <T> RetryWithRecoveryBuilder<T> from(RetryWithRecoveryBuilder<?> from)
supplier
.T
- the target parametrized type.from
- the RetryWithRecovery
to be copied.public static <T> RetryWithRecoveryBuilder<T> copyWithoutRecoveryStrategies(RetryWithRecoveryBuilder<?> from)
public static boolean isNetworkOrMinorError(java.lang.Throwable t)
ApiException
minor error.
This is the default function used in RetryWithRecovery
to check if a given exception thrown should lead to a retry.t
- the throwable to be checked.SocketTimeoutException
or ConnectException
or if it is a ApiException
which ApiException.isServerError()
or ApiException.isUnauthorized()
or ApiException.isTooManyRequestsError()
.public static boolean isNetworkOrMinorErrorOrClientError(java.lang.Throwable t)
ApiException
minor error or client error.t
- the throwable to be checked.SocketTimeoutException
or ConnectException
or if it is a ApiException
which ApiException.isServerError()
or ApiException.isUnauthorized()
or ApiException.isTooManyRequestsError()
or ApiException.isClientError()
.public RetryWithRecoveryBuilder<T> name(java.lang.String name)
name
- the name of the RetryWithRecovery
public RetryWithRecoveryBuilder<T> retryConfig(BdkRetryConfig retryConfig)
retryConfig
- the retry configuration to be used.public RetryWithRecoveryBuilder<T> basePath(java.lang.String address)
address
- that we are trying to reach.public RetryWithRecoveryBuilder<T> supplier(SupplierWithApiException<T> supplier)
supplier
- the function to be called by the RetryWithRecovery
which returns the desired object and which may fail.public RetryWithRecoveryBuilder<T> retryOnException(java.util.function.Predicate<java.lang.Throwable> retryOnExceptionPredicate)
supplier
.retryOnExceptionPredicate
- the condition when we should retry the call
when the supplier
throws an exception.public RetryWithRecoveryBuilder<T> ignoreException(java.util.function.Predicate<com.symphony.bdk.http.api.ApiException> ignoreException)
ApiException
thrown by the supplier
and return null in RetryWithRecovery.execute()
.ignoreException
- the condition when we should ignore a given exceptionpublic RetryWithRecoveryBuilder<T> recoveryStrategy(java.util.function.Predicate<com.symphony.bdk.http.api.ApiException> condition, ConsumerWithThrowable recovery)
ApiException
and of a corresponding recovery function to be executed when condition is met.condition
- the predicate to check if the exception should lead to the execution of the recovery function.recovery
- the recovery function to be executed when condition is fulfilled.public <E extends java.lang.Exception> RetryWithRecoveryBuilder<T> recoveryStrategy(java.lang.Class<? extends E> exceptionType, ConsumerWithThrowable recovery)
Exception
type
and of a corresponding recovery function to be executed when exception is of the given provided type.E
- the actual exception classexceptionType
- the actual exception classrecovery
- the recovery function to be executed when condition is fulfilled.public RetryWithRecoveryBuilder<T> clearRecoveryStrategies()
public RetryWithRecovery<T> build()
RetryWithRecovery
based on provided fields.RetryWithRecovery
based on the provided fields.