RetryConfig
Kind: class
Module/package: com.pdfdancer.client.rest
SDK: com.pdfdancer.client:pdfdancer-client-java 2.0.0
Configuration for HTTP request retry behavior.
This class defines when and how HTTP requests should be retried on failure. It supports configurable retry attempts, exponential backoff, and selective retrying based on HTTP status codes or exception types.
Example Usage:
// Retry up to 3 times with exponential backoff RetryConfig config = RetryConfig.builder() .maxAttempts(3) .initialDelay(Duration.ofMillis(100)) .backoffMultiplier(2.0) .retryOnStatus(429, 503, 504) .build();
Declaration
public final class com.pdfdancer.client.rest.RetryConfig
Members
builder
public static com.pdfdancer.client.rest.RetryConfig$Builder builder()
Creates a new builder for constructing a RetryConfig.
defaultConfig
public static com.pdfdancer.client.rest.RetryConfig defaultConfig()
Creates a default retry configuration suitable for most scenarios.
Default settings:
Max attempts: 3 (2 retries) Initial delay: 1 second Backoff multiplier: 2.0 (exponential backoff) Max delay: 5 seconds Retryable status codes: 408, 429, 500, 502, 503, 504, 520 Retry on timeout: true Retry on connection error: true
getBackoffMultiplier
public double getBackoffMultiplier()
Gets the backoff multiplier for exponential backoff. Each retry delay is calculated as: initialDelay * (backoffMultiplier ^ attempt)
getInitialDelay
public java.time.Duration getInitialDelay()
Gets the initial delay before the first retry.
getMaxAttempts
public int getMaxAttempts()
Gets the maximum number of attempts (including the initial request). A value of 1 means no retries, 2 means 1 retry, etc.
getMaxDelay
public java.time.Duration getMaxDelay()
Gets the maximum delay between retry attempts.
getRetryableStatusCodes
public java.util.Set<java.lang.Integer> getRetryableStatusCodes()
Gets the set of HTTP status codes that should trigger a retry.
isRetryableStatusCode
public boolean isRetryableStatusCode(int)
Checks if a specific HTTP status code is retryable.
isRetryOnConnectionError
public boolean isRetryOnConnectionError()
Determines if requests should be retried on connection errors (IOException).
isRetryOnTimeout
public boolean isRetryOnTimeout()
Determines if requests should be retried on timeout exceptions.
noRetry
public static com.pdfdancer.client.rest.RetryConfig noRetry()
Creates a default retry configuration with no retries.