Class CircuitBreakerPolicy
- java.lang.Object
-
- fish.payara.microprofile.faulttolerance.policy.Policy
-
- fish.payara.microprofile.faulttolerance.policy.CircuitBreakerPolicy
-
- All Implemented Interfaces:
Serializable
public final class CircuitBreakerPolicy extends Policy
The resolved "cached" information of aCircuitBreakerannotation an a specific method.- Author:
- Jan Bernitt
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description longdelayChronoUnitdelayUnitdoublefailureRatiointrequestVolumeThresholdintsuccessThreshold
-
Constructor Summary
Constructors Constructor Description CircuitBreakerPolicy(Method annotatedMethod, Class<? extends Throwable>[] failOn, Class<? extends Throwable>[] skipOn, long delay, ChronoUnit delayUnit, int requestVolumeThreshold, double failureRatio, int successThreshold)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static CircuitBreakerPolicycreate(jakarta.interceptor.InvocationContext context, FaultToleranceConfig config)booleanisFailure(Throwable ex)Helper method that checks whether or not the given exception is considered a success or failure.-
Methods inherited from class fish.payara.microprofile.faulttolerance.policy.Policy
checkAtLeast, checkAtLeast, checkAtLeast, checkAtMost, checkReturnsSameAs, checkReturnsSameAs, describe, isCaught
-
-
-
-
Field Detail
-
delay
public final long delay
-
delayUnit
public final ChronoUnit delayUnit
-
requestVolumeThreshold
public final int requestVolumeThreshold
-
failureRatio
public final double failureRatio
-
successThreshold
public final int successThreshold
-
-
Method Detail
-
create
public static CircuitBreakerPolicy create(jakarta.interceptor.InvocationContext context, FaultToleranceConfig config)
-
isFailure
public boolean isFailure(Throwable ex)
Helper method that checks whether or not the given exception is considered a success or failure. Relevant part from theCircuitBreakerdocumentation:When a method returns a result, the following rules are applied to determine whether the result is a success or a failure:
- If the method does not throw a
Throwable, it is considered a success - Otherwise, if the thrown object is assignable to any value in the
#skipOn()parameter, is is considered a success - Otherwise, if the thrown object is assignable to any value in the
#failOn()parameter, it is considered a failure - Otherwise it is considered a success
- Parameters:
ex- The exception to check- Returns:
- True if the exception is considered a failure, false if it is considered a success.
- If the method does not throw a
-
-