Class CircuitBreakerPolicy

  • All Implemented Interfaces:
    Serializable

    public final class CircuitBreakerPolicy
    extends Policy
    The resolved "cached" information of a CircuitBreaker annotation an a specific method.
    Author:
    Jan Bernitt
    See Also:
    Serialized Form
    • Field Detail

      • delay

        public final long delay
      • requestVolumeThreshold

        public final int requestVolumeThreshold
      • failureRatio

        public final double failureRatio
      • successThreshold

        public final int successThreshold
    • Constructor Detail

      • CircuitBreakerPolicy

        public CircuitBreakerPolicy​(Method annotatedMethod,
                                    Class<? extends Throwable>[] failOn,
                                    Class<? extends Throwable>[] skipOn,
                                    long delay,
                                    ChronoUnit delayUnit,
                                    int requestVolumeThreshold,
                                    double failureRatio,
                                    int successThreshold)
    • Method Detail

      • 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 the CircuitBreaker documentation:
        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.