Class RetryUtils
java.lang.Object
dev.hogwai.dynamodb.simplified.internal.RetryUtils
Shared utility for retry-related operations.
Consolidates duplicated backoff and retry logic across sync builders.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longDefault base backoff in milliseconds for exponential retry.static final intDefault maximum number of retry attempts. -
Method Summary
Modifier and TypeMethodDescriptionstatic booleansleepWithBackoff(int attempt) Sleeps with exponential backoff plus jitter using the default base of 100ms.static booleansleepWithBackoff(int attempt, long baseBackoffMs) Sleeps with exponential backoff plus jitter.
-
Field Details
-
DEFAULT_BASE_BACKOFF_MS
public static final long DEFAULT_BASE_BACKOFF_MSDefault base backoff in milliseconds for exponential retry.- See Also:
-
DEFAULT_MAX_RETRIES
public static final int DEFAULT_MAX_RETRIESDefault maximum number of retry attempts.- See Also:
-
-
Method Details
-
sleepWithBackoff
public static boolean sleepWithBackoff(int attempt, long baseBackoffMs) Sleeps with exponential backoff plus jitter.Formula:
baseBackoffMs * (1 << attempt) + random(baseBackoffMs)- Parameters:
attempt- the current retry attempt (0-based)baseBackoffMs- the base backoff in milliseconds- Returns:
trueif the sleep was interrupted (caller should abort retry),falseif the sleep completed normally
-
sleepWithBackoff
public static boolean sleepWithBackoff(int attempt) Sleeps with exponential backoff plus jitter using the default base of 100ms.- Parameters:
attempt- the current retry attempt (0-based)- Returns:
trueif interrupted,falseotherwise- See Also:
-