Class RetryAfterDelay
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleancanRetryWithin(ApiHttpException exception, long maxDelayMillis) static booleancanRetryWithin(ApiHttpHeaders headers, int statusCode, long maxDelayMillis) Whether a rate-limited response can usefully be retried within the configured maximum delay.static DurationforContext(dev.failsafe.ExecutionContext<ApiHttpResponse<byte[]>> context, long initialDelayMillis, long maxDelayMillis) static booleanhasTiming(ApiHttpException exception) static booleanhasTiming(ApiHttpHeaders headers, int statusCode) of(ApiHttpException exception, Instant now) of(ApiHttpHeaders headers, int statusCode, Instant now)
-
Method Details
-
parse
-
of
-
hasTiming
-
of
-
hasTiming
-
canRetryWithin
public static boolean canRetryWithin(@Nullable ApiHttpHeaders headers, int statusCode, long maxDelayMillis) Whether a rate-limited response can usefully be retried within the configured maximum delay.A rate limit window is a hard boundary: until it resets, every request is rejected. So if the server asks for longer than we are willing to wait, capping the delay does not salvage the retry — it guarantees the next attempt lands inside the same window and fails again, and the one after that, until the budget is gone. The caller ends up waiting
maxRetries * maxDelayand still gets the error, having added load to a server that was already shedding it.Failing immediately is more useful: the caller gets the
429straight away and can decide what to do with it, rather than being blocked on attempts that cannot succeed.This applies to
429only. ARetry-Afteron a503is the server's estimate of when it might recover, not a hard boundary, so an early retry there may well succeed and the delay is capped rather than abandoned.- Returns:
falsewhen there is no timing header at all, or when the wait it asks for exceedsmaxDelayMillis
-
canRetryWithin
-
forContext
public static Duration forContext(dev.failsafe.ExecutionContext<ApiHttpResponse<byte[]>> context, long initialDelayMillis, long maxDelayMillis)
-