Class RetryPolicy

java.lang.Object
dev.restate.sdk.common.RetryPolicy

public final class RetryPolicy extends Object
Retry policy configuration.
  • Method Details

    • setInitialDelay

      public RetryPolicy setInitialDelay(Duration initialDelay)
      Initial retry delay for the first retry attempt.
    • setExponentiationFactor

      public RetryPolicy setExponentiationFactor(float exponentiationFactor)
      Exponentiation factor to use when computing the next retry delay.
    • setMaxDelay

      public RetryPolicy setMaxDelay(@Nullable Duration maxDelay)
      Maximum delay between retries.
    • setMaxAttempts

      public RetryPolicy setMaxAttempts(@Nullable Integer maxAttempts)
      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 with setMaxDuration(Duration) (if set) is reached first. If both getMaxAttempts() and getMaxDuration() are null, 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

      public RetryPolicy setMaxDuration(@Nullable Duration maxDuration)
      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 with setMaxAttempts(Integer) (if set) is reached first. If both getMaxAttempts() and getMaxDuration() are null, 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

      public Duration getInitialDelay()
      See Also:
    • getExponentiationFactor

      public float getExponentiationFactor()
      See Also:
    • getMaxDelay

      public @Nullable Duration getMaxDelay()
      See Also:
    • getMaxAttempts

      public @Nullable Integer getMaxAttempts()
      See Also:
    • getMaxDuration

      public @Nullable Duration getMaxDuration()
      See Also:
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • defaultPolicy

      public static RetryPolicy defaultPolicy()
      Returns:
      a default exponential bounded retry policy
    • exponential

      public static RetryPolicy exponential(Duration initialDelay, float factor)
      Returns:
      an unbounded retry policy, with the given initial delay and factor.
      See Also: