public final class RetryableSphereClientWithExponentialBackoff
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected static long |
DEFAULT_INITIAL_RETRY_DELAY |
protected static long |
DEFAULT_MAX_DELAY |
protected static int |
DEFAULT_MAX_PARALLEL_REQUESTS |
protected static int |
DEFAULT_MAX_RETRY_ATTEMPT |
| Modifier and Type | Method and Description |
|---|---|
io.sphere.sdk.client.SphereClient |
build()
creates a SphereClient using the class configuration values.
|
java.time.Duration |
calculateDurationWithExponentialRandomBackoff(long retryAttempt,
long initialRetryDelay,
long maxDelay)
Computes a exponential backoff time delay in milliseconds to be used in retries, the delay grows with failed
retry attempts count with a randomness interval.
|
protected io.sphere.sdk.client.SphereClient |
createUnderlyingSphereClient(io.sphere.sdk.client.SphereClientConfig clientConfig) |
protected io.sphere.sdk.client.SphereClient |
decorateSphereClient(io.sphere.sdk.client.SphereClient underlyingClient,
long maxRetryAttempt,
java.util.function.Function<io.sphere.sdk.retry.RetryContext,java.time.Duration> durationFunction,
int maxParallelRequests) |
protected io.sphere.sdk.http.HttpClient |
getHttpClient()
Gets an asynchronous
HttpClient to be used by the BlockingSphereClient. |
static RetryableSphereClientWithExponentialBackoff |
of(io.sphere.sdk.client.SphereClientConfig sphereClientConfig)
Creates a new instance of
RetryableSphereClientWithExponentialBackoff given a SphereClientConfig
responsible for creation of a SphereClient. |
RetryableSphereClientWithExponentialBackoff |
withInitialDelay(long initialDelay)
Sets the initialDelay value in milliseconds.
|
RetryableSphereClientWithExponentialBackoff |
withMaxDelay(long maxDelay)
Sets the maxDelay value value in milliseconds.
|
RetryableSphereClientWithExponentialBackoff |
withMaxParallelRequests(int maxParallelRequests)
Sets the Max Parallel Requests value, It should be always positive number.
|
RetryableSphereClientWithExponentialBackoff |
withMaxRetryAttempt(int maxRetryAttempt)
Sets the Max Retry value, It should be greater than 1 for the Retry attempt.
|
RetryableSphereClientWithExponentialBackoff |
withStatusCodesToRetry(java.util.List<java.lang.Integer> statusCodesToRetry)
Sets the Retry Error Status Codes.
|
protected static final long DEFAULT_MAX_DELAY
protected static final long DEFAULT_INITIAL_RETRY_DELAY
protected static final int DEFAULT_MAX_RETRY_ATTEMPT
protected static final int DEFAULT_MAX_PARALLEL_REQUESTS
public static RetryableSphereClientWithExponentialBackoff of(@Nonnull io.sphere.sdk.client.SphereClientConfig sphereClientConfig)
RetryableSphereClientWithExponentialBackoff given a SphereClientConfig
responsible for creation of a SphereClient.sphereClientConfig - the client configuration for the client.RetryableSphereClientWithExponentialBackoff.public RetryableSphereClientWithExponentialBackoff withMaxDelay(long maxDelay)
maxDelay - - build with maxDelay value.RetryableSphereClientWithExponentialBackoff with given maxDelay value.public RetryableSphereClientWithExponentialBackoff withInitialDelay(long initialDelay)
initialDelay - - build with initialDelay value.
If initialDelay is equal or greater than maxDelay then, a IllegalArgumentException will be thrown.RetryableSphereClientWithExponentialBackoff with given initialDelay value.public RetryableSphereClientWithExponentialBackoff withMaxRetryAttempt(int maxRetryAttempt)
maxRetryAttempt - - build with maxRetries value.
If maxRetryAttempt is less than 1 then, a IllegalArgumentException will be thrown.RetryableSphereClientWithExponentialBackoff with given maxRetries value.public RetryableSphereClientWithExponentialBackoff withMaxParallelRequests(int maxParallelRequests)
maxParallelRequests - - build with maxParallelRequests value.
If maxParallelRequests is less than 1 then, a IllegalArgumentException will be thrown.RetryableSphereClientWithExponentialBackoff with given maxParallelRequests value.public RetryableSphereClientWithExponentialBackoff withStatusCodesToRetry(java.util.List<java.lang.Integer> statusCodesToRetry)
statusCodesToRetry - - build with retryErrorStatusCodes.RetryableSphereClientWithExponentialBackoff with given retryErrorStatusCodes.public io.sphere.sdk.client.SphereClient build()
SphereClientprotected io.sphere.sdk.client.SphereClient createUnderlyingSphereClient(@Nonnull
io.sphere.sdk.client.SphereClientConfig clientConfig)
protected io.sphere.sdk.client.SphereClient decorateSphereClient(@Nonnull
io.sphere.sdk.client.SphereClient underlyingClient,
long maxRetryAttempt,
@Nonnull
java.util.function.Function<io.sphere.sdk.retry.RetryContext,java.time.Duration> durationFunction,
int maxParallelRequests)
protected io.sphere.sdk.http.HttpClient getHttpClient()
HttpClient to be used by the BlockingSphereClient.HttpClientpublic java.time.Duration calculateDurationWithExponentialRandomBackoff(long retryAttempt,
long initialRetryDelay,
long maxDelay)
retryAttempt - the number of attempts already tried by the client.initialRetryDelay - the initial Retry delay.maxDelay - the maxDelay in milliseconds.