Package com.fauna.client
Class ExponentialBackoffStrategy
- java.lang.Object
-
- com.fauna.client.ExponentialBackoffStrategy
-
- All Implemented Interfaces:
RetryStrategy
public final class ExponentialBackoffStrategy extends java.lang.Object implements RetryStrategy
Implements an exponential backoff strategy for retries. The backoff delay increases exponentially with each retry attempt, with optional jitter.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classExponentialBackoffStrategy.BuilderBuilder class for the ExponentialBackoffStrategy.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ExponentialBackoffStrategy.Builderbuilder()Creates a new Builder instance for ExponentialBackoffStrategy.booleancanRetry(int retryAttempt)Returns true if the given retry attempt will be allowed by this strategy.intgetDelayMillis(int retryAttempt)Return the number of milliseconds to delay the next retry attempt.intgetMaxRetryAttempts()Return the maximum number of retry attempts for this strategy.
-
-
-
Method Detail
-
canRetry
public boolean canRetry(int retryAttempt)
Description copied from interface:RetryStrategyReturns true if the given retry attempt will be allowed by this strategy.- Specified by:
canRetryin interfaceRetryStrategy- Parameters:
retryAttempt- The retry attempt number, starting at 1 (i.e. the second overall attempt, or first retry is attempt 1).- Returns:
- True if this attempt can be retried, otherwise false.
-
getDelayMillis
public int getDelayMillis(int retryAttempt)
Description copied from interface:RetryStrategyReturn the number of milliseconds to delay the next retry attempt.- Specified by:
getDelayMillisin interfaceRetryStrategy- Parameters:
retryAttempt- The retry attempt number, starting at 1 (i.e. the second overall attempt/first retry is #1).- Returns:
- The number of milliseconds to delay the next retry attempt.
-
getMaxRetryAttempts
public int getMaxRetryAttempts()
Description copied from interface:RetryStrategyReturn the maximum number of retry attempts for this strategy.- Specified by:
getMaxRetryAttemptsin interfaceRetryStrategy- Returns:
- The number of retry attempts that this strategy will attempt.
-
builder
public static ExponentialBackoffStrategy.Builder builder()
Creates a new Builder instance for ExponentialBackoffStrategy.- Returns:
- A new Builder instance.
-
-