Class RetryPolicy
java.lang.Object
codes.grow.packages.skywalking.core.RetryPolicy
Retry settings with full-jitter exponential backoff (SPEC section 2.3).
Backoff before retry n (0-based) is a uniform random value in [0,
min(maxBackoff, initialBackoff * multiplier^n)).
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault maximum number of retries (so up to 4 attempts). -
Method Summary
Modifier and TypeMethodDescriptionbackoff(int retry) Computes the full-jitter backoff for retryn.backoffCap(int retry) Returns the upper bound of the jitter window for retryn.static RetryPolicy.Builderbuilder()Starts a builder with the defaults.static RetryPolicydefaults()Returns the default policy: 3 retries, 100 ms initial, 10 s max, multiplier 2, Retry-After up to 60 s.Returns the backoff cap for the first retry.Returns the upper bound of any backoff.intReturns the maximum number of retries after the first attempt.Returns the longestRetry-Afterwait the client accepts.doubleReturns the exponential growth factor.static RetryPolicynone()Returns a policy that never retries.parseRateLimitReset(String value, Instant now) Parses a vendor rate-limit reset header such asX-RateLimit-Reset: delay seconds (decimals allowed), Unix epoch seconds (values of at least1000000000) or an HTTP-date.parseRetryAfter(String value, Instant now) Parses aRetry-Afterheader: delay seconds or an HTTP-date.Returns a builder initialised from this policy.toString()
-
Field Details
-
DEFAULT_MAX_RETRIES
public static final int DEFAULT_MAX_RETRIESDefault maximum number of retries (so up to 4 attempts).- See Also:
-
-
Method Details
-
defaults
Returns the default policy: 3 retries, 100 ms initial, 10 s max, multiplier 2, Retry-After up to 60 s.- Returns:
- the default policy
-
none
Returns a policy that never retries.- Returns:
- a policy with
maxRetries = 0
-
builder
Starts a builder with the defaults.- Returns:
- a new builder
-
toBuilder
Returns a builder initialised from this policy.- Returns:
- a new builder
-
maxRetries
public int maxRetries()Returns the maximum number of retries after the first attempt.- Returns:
- retries,
>= 0
-
initialBackoff
Returns the backoff cap for the first retry.- Returns:
- the initial backoff
-
maxBackoff
Returns the upper bound of any backoff.- Returns:
- the maximum backoff
-
multiplier
public double multiplier()Returns the exponential growth factor.- Returns:
- the multiplier
-
maxRetryAfter
Returns the longestRetry-Afterwait the client accepts.- Returns:
- the maximum Retry-After
-
backoffCap
Returns the upper bound of the jitter window for retryn.- Parameters:
retry- 0-based retry number- Returns:
min(maxBackoff, initialBackoff * multiplier^retry)
-
backoff
Computes the full-jitter backoff for retryn.- Parameters:
retry- 0-based retry number- Returns:
- a uniform random duration in
[0, backoffCap(retry))
-
parseRetryAfter
Parses aRetry-Afterheader: delay seconds or an HTTP-date.- Parameters:
value- header value, may be nullnow- current time, used for HTTP-dates- Returns:
- the wait (never negative), or empty when absent or unparseable
-
parseRateLimitReset
Parses a vendor rate-limit reset header such asX-RateLimit-Reset: delay seconds (decimals allowed), Unix epoch seconds (values of at least1000000000) or an HTTP-date.- Parameters:
value- header value, may be nullnow- current time, used for epoch seconds and HTTP-dates- Returns:
- the wait (never negative), or empty when absent or unparseable
-
toString
-