Record Class CircuitBreakerPolicy
java.lang.Object
java.lang.Record
io.micronaut.retry.CircuitBreakerPolicy
- Record Components:
retryPolicy- The retry policy used by the circuit breakerresetTimeout- The timeout before the circuit transitions to half openthrowWrappedException- 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
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCircuitBreakerPolicy(RetryPolicy retryPolicy, Duration resetTimeout, boolean throwWrappedException) Creates an instance of aCircuitBreakerPolicyrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the retry policy view of this circuit breaker policy.static CircuitBreakerPolicy.Builderbuilder()Creates a circuit breaker policy builder.final booleanIndicates whether some other object is "equal to" this one.Returns the captured exception type.getDelay()Returns the delay between retry attempts.Returns the excluded exception types.Returns the included exception types.doubleReturns the retry jitter factor.intReturns the maximum number of attempts.Returns the maximum overall delay.doubleReturns the delay multiplier.Returns the retry predicate.Returns the circuit reset timeout.final inthashCode()Returns a hash code value for this object.booleanReturns whether open-circuit exceptions should be wrapped.Returns the value of theresetTimeoutrecord component.Returns the value of theretryPolicyrecord component.booleanReturns the value of thethrowWrappedExceptionrecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
DEFAULT_DELAY
-
DEFAULT_MAX_DELAY
-
DEFAULT_MULTIPLIER
public static final double DEFAULT_MULTIPLIER- See Also:
-
DEFAULT_RESET_TIMEOUT
-
-
Constructor Details
-
CircuitBreakerPolicy
public CircuitBreakerPolicy(RetryPolicy retryPolicy, Duration resetTimeout, boolean throwWrappedException) Creates an instance of aCircuitBreakerPolicyrecord class.- Parameters:
retryPolicy- the value for theretryPolicyrecord componentresetTimeout- the value for theresetTimeoutrecord componentthrowWrappedException- the value for thethrowWrappedExceptionrecord component
-
-
Method Details
-
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
Returns the delay between retry attempts.- Returns:
- The delay between retry attempts
-
getMaxDelay
-
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
-
getCapturedException
-
getIncludes
-
getExcludes
-
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
Returns the retry policy view of this circuit breaker policy.- Returns:
- The retry policy view
-
toString
-
hashCode
-
equals
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 withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
retryPolicy
Returns the value of theretryPolicyrecord component.- Returns:
- the value of the
retryPolicyrecord component
-
resetTimeout
Returns the value of theresetTimeoutrecord component.- Returns:
- the value of the
resetTimeoutrecord component
-
throwWrappedException
public boolean throwWrappedException()Returns the value of thethrowWrappedExceptionrecord component.- Returns:
- the value of the
throwWrappedExceptionrecord component
-