Record Class RetryPolicy

java.lang.Object
java.lang.Record
io.micronaut.retry.RetryPolicy
Record Components:
maxAttempts - The maximum number of attempts
delay - The delay between retry attempts
maxDelay - The maximum overall delay
multiplier - The delay multiplier
jitter - The retry jitter factor
predicate - The retry predicate
capturedException - The captured exception type
includes - The included exception types
excludes - The excluded exception types

public record RetryPolicy(int maxAttempts, Duration delay, @Nullable Duration maxDelay, double multiplier, double jitter, RetryPredicate predicate, Class<? extends Throwable> capturedException, List<Class<? extends Throwable>> includes, List<Class<? extends Throwable>> excludes) extends Record
Typed retry policy for programmatic retry execution.
Since:
5.0.0
Author:
graemerocher
  • Field Details

    • DEFAULT_MAX_ATTEMPTS

      public static final int DEFAULT_MAX_ATTEMPTS
      See Also:
    • DEFAULT_DELAY

      public static final Duration DEFAULT_DELAY
    • DEFAULT_MULTIPLIER

      public static final double DEFAULT_MULTIPLIER
      See Also:
    • DEFAULT_JITTER

      public static final double DEFAULT_JITTER
      See Also:
    • DEFAULT_CAPTURED_EXCEPTION

      public static final Class<? extends Throwable> DEFAULT_CAPTURED_EXCEPTION
  • Constructor Details

    • RetryPolicy

      public RetryPolicy(int maxAttempts, Duration delay, @Nullable Duration maxDelay, double multiplier, double jitter, RetryPredicate predicate, Class<? extends Throwable> capturedException, List<Class<? extends Throwable>> includes, List<Class<? extends Throwable>> excludes)
      Creates an instance of a RetryPolicy record class.
      Parameters:
      maxAttempts - the value for the maxAttempts record component
      delay - the value for the delay record component
      maxDelay - the value for the maxDelay record component
      multiplier - the value for the multiplier record component
      jitter - the value for the jitter record component
      predicate - the value for the predicate record component
      capturedException - the value for the capturedException record component
      includes - the value for the includes record component
      excludes - the value for the excludes record component
  • Method Details

    • builder

      public static RetryPolicy.Builder builder()
      Creates a retry policy builder.
      Returns:
      A retry policy builder
    • getMaxDelay

      public Optional<Duration> getMaxDelay()
      Returns the maximum overall delay.
      Returns:
      The maximum overall delay if configured
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • maxAttempts

      public int maxAttempts()
      Returns the value of the maxAttempts record component.
      Returns:
      the value of the maxAttempts record component
    • delay

      public Duration delay()
      Returns the value of the delay record component.
      Returns:
      the value of the delay record component
    • maxDelay

      public @Nullable Duration maxDelay()
      Returns the value of the maxDelay record component.
      Returns:
      the value of the maxDelay record component
    • multiplier

      public double multiplier()
      Returns the value of the multiplier record component.
      Returns:
      the value of the multiplier record component
    • jitter

      public double jitter()
      Returns the value of the jitter record component.
      Returns:
      the value of the jitter record component
    • predicate

      public RetryPredicate predicate()
      Returns the value of the predicate record component.
      Returns:
      the value of the predicate record component
    • capturedException

      public Class<? extends Throwable> capturedException()
      Returns the value of the capturedException record component.
      Returns:
      the value of the capturedException record component
    • includes

      public List<Class<? extends Throwable>> includes()
      Returns the value of the includes record component.
      Returns:
      the value of the includes record component
    • excludes

      public List<Class<? extends Throwable>> excludes()
      Returns the value of the excludes record component.
      Returns:
      the value of the excludes record component