Record Class CircuitBreakerPolicy

java.lang.Object
java.lang.Record
io.micronaut.retry.CircuitBreakerPolicy
Record Components:
retryPolicy - The retry policy used by the circuit breaker
resetTimeout - The timeout before the circuit transitions to half open
throwWrappedException - Whether open-circuit exceptions should be wrapped

public record CircuitBreakerPolicy(RetryPolicy retryPolicy, Duration resetTimeout, boolean throwWrappedException) extends Record
Typed circuit breaker policy for programmatic execution.
Since:
5.0.0
Author:
graemerocher
  • Field Details

    • DEFAULT_DELAY

      public static final Duration DEFAULT_DELAY
    • DEFAULT_MAX_DELAY

      public static final Duration DEFAULT_MAX_DELAY
    • DEFAULT_MULTIPLIER

      public static final double DEFAULT_MULTIPLIER
      See Also:
    • DEFAULT_RESET_TIMEOUT

      public static final Duration DEFAULT_RESET_TIMEOUT
  • Constructor Details

    • CircuitBreakerPolicy

      public CircuitBreakerPolicy(RetryPolicy retryPolicy, Duration resetTimeout, boolean throwWrappedException)
      Creates an instance of a CircuitBreakerPolicy record class.
      Parameters:
      retryPolicy - the value for the retryPolicy record component
      resetTimeout - the value for the resetTimeout record component
      throwWrappedException - the value for the throwWrappedException record component
  • Method Details

    • builder

      public static CircuitBreakerPolicy.Builder builder()
      Creates a circuit breaker policy builder.
      Returns:
      A circuit breaker policy builder
    • getMaxAttempts

      public int getMaxAttempts()
      Returns the maximum number of attempts.
      Returns:
      The maximum number of attempts
    • getDelay

      public Duration getDelay()
      Returns the delay between retry attempts.
      Returns:
      The delay between retry attempts
    • getMaxDelay

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

      public double getMultiplier()
      Returns the delay multiplier.
      Returns:
      The delay multiplier
    • getJitter

      public double getJitter()
      Returns the retry jitter factor.
      Returns:
      The retry jitter factor
    • getPredicate

      public RetryPredicate getPredicate()
      Returns the retry predicate.
      Returns:
      The retry predicate
    • getCapturedException

      public Class<? extends Throwable> getCapturedException()
      Returns the captured exception type.
      Returns:
      The captured exception type
    • getIncludes

      public List<Class<? extends Throwable>> getIncludes()
      Returns the included exception types.
      Returns:
      The included exception types
    • getExcludes

      public List<Class<? extends Throwable>> getExcludes()
      Returns the excluded exception types.
      Returns:
      The excluded exception types
    • getResetTimeout

      public Duration getResetTimeout()
      Returns the circuit reset timeout.
      Returns:
      The circuit reset timeout
    • isThrowWrappedException

      public boolean isThrowWrappedException()
      Returns whether open-circuit exceptions should be wrapped.
      Returns:
      Whether open-circuit exceptions should be wrapped
    • asRetryPolicy

      public RetryPolicy asRetryPolicy()
      Returns the retry policy view of this circuit breaker policy.
      Returns:
      The retry policy view
    • 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.
    • retryPolicy

      public RetryPolicy retryPolicy()
      Returns the value of the retryPolicy record component.
      Returns:
      the value of the retryPolicy record component
    • resetTimeout

      public Duration resetTimeout()
      Returns the value of the resetTimeout record component.
      Returns:
      the value of the resetTimeout record component
    • throwWrappedException

      public boolean throwWrappedException()
      Returns the value of the throwWrappedException record component.
      Returns:
      the value of the throwWrappedException record component