Class CircuitBreaker.Builder

    • Method Detail

      • delay

        public CircuitBreaker.Builder delay​(Duration delay)
        How long to wait before transitioning from open to half-open state.
        Parameters:
        delay - to wait
        Returns:
        updated builder instance
      • errorRatio

        public CircuitBreaker.Builder errorRatio​(int ratio)
        How many failures out of 100 will trigger the circuit to open. This is adapted to the volume(int) used to handle the window of requests.

        If errorRatio is 40, and volume is 10, 4 failed requests will open the circuit.

        Parameters:
        ratio - percent of failure that trigger the circuit to open
        Returns:
        updated builder instance
        See Also:
        volume(int)
      • successThreshold

        public CircuitBreaker.Builder successThreshold​(int successThreshold)
        How many successful calls will close a half-open circuit. Nevertheless the first failed call will open the circuit again.
        Parameters:
        successThreshold - number of calls
        Returns:
        updated builder instance
      • volume

        public CircuitBreaker.Builder volume​(int volume)
        Rolling window size used to calculate ratio of failed requests.
        Parameters:
        volume - how big a window is used to calculate error errorRatio
        Returns:
        updated builder instance
        See Also:
        errorRatio(int)
      • applyOn

        public CircuitBreaker.Builder applyOn​(Class<? extends Throwable>... classes)
        These throwables will be considered failures, and all other will not.

        Cannot be combined with skipOn.

        Parameters:
        classes - to consider failures to calculate failure ratio
        Returns:
        updated builder instance
      • addApplyOn

        public CircuitBreaker.Builder addApplyOn​(Class<? extends Throwable> clazz)
        Add a throwable to be considered a failure.
        Parameters:
        clazz - to consider failure to calculate failure ratio
        Returns:
        updated builder instance
        See Also:
        applyOn
      • skipOn

        public CircuitBreaker.Builder skipOn​(Class<? extends Throwable>... classes)
        These throwables will not be considered failures, all other will.

        Cannot be combined with applyOn.

        Parameters:
        classes - to consider successful
        Returns:
        updated builder instance
      • addSkipOn

        public CircuitBreaker.Builder addSkipOn​(Class<? extends Throwable> clazz)
        This throwable will not be considered failure.

        Parameters:
        clazz - to consider successful
        Returns:
        updated builder instance