Class RetryPolicy
-
Method Summary
Modifier and TypeMethodDescriptionstatic RetryPolicy
boolean
static RetryPolicy
exponential
(Duration initialDelay, float factor) float
@Nullable Integer
@Nullable Duration
@Nullable Duration
int
hashCode()
setExponentiationFactor
(float exponentiationFactor) Exponentiation factor to use when computing the next retry delay.setInitialDelay
(Duration initialDelay) Initial retry delay for the first retry attempt.setMaxAttempts
(@Nullable Integer maxAttempts) Maximum number of attempts before giving up retrying.setMaxDelay
(@Nullable Duration maxDelay) Maximum delay between retries.setMaxDuration
(@Nullable Duration maxDuration) Maximum duration of the retry loop.toString()
-
Method Details
-
setInitialDelay
Initial retry delay for the first retry attempt. -
setExponentiationFactor
Exponentiation factor to use when computing the next retry delay. -
setMaxDelay
Maximum delay between retries. -
setMaxAttempts
Maximum number of attempts before giving up retrying.The policy gives up retrying when either at least the given number of attempts is reached, or the
maxDuration
specified withsetMaxDuration(Duration)
(if set) is reached first. If bothgetMaxAttempts()
andgetMaxDuration()
arenull
, the policy will retry indefinitely.Note: The number of actual retries may be higher than the provided value. This is due to the nature of the
run
operation, which executes the closure on the service and sends the result afterward to Restate. -
setMaxDuration
Maximum duration of the retry loop.The policy gives up retrying when either the retry loop lasted at least for this given max duration, or the
maxAttempts
specified withsetMaxAttempts(Integer)
(if set) is reached first. If bothgetMaxAttempts()
andgetMaxDuration()
arenull
, the policy will retry indefinitely.Note: The real retry loop duration may be higher than the given duration. TThis is due to the nature of the
run
operation, which executes the closure on the service and sends the result afterward to Restate. -
getInitialDelay
- See Also:
-
getExponentiationFactor
public float getExponentiationFactor()- See Also:
-
getMaxDelay
- See Also:
-
getMaxAttempts
- See Also:
-
getMaxDuration
- See Also:
-
equals
-
hashCode
public int hashCode() -
toString
-
defaultPolicy
- Returns:
- a default exponential bounded retry policy
-
exponential
- Returns:
- an unbounded retry policy, with the given initial delay and factor.
- See Also:
-