io.vertx.circuitbreaker

## Interface FailurePolicy<T>

- All Superinterfaces:
    java.util.function.Predicate<Future<T>>

      public interface FailurePolicy<T>
      extends java.util.function.Predicate<Future<T>>

  A failure policy for the `CircuitBreaker`.

  The default policy is to consider an asynchronous result as a failure if `AsyncResult.failed()` returns `true`. Nevertheless, sometimes this is not good enough. For example, an HTTP Client could return a response, but with an unexpected status code.

  In this case, a custom failure policy can be configured with `CircuitBreaker.failurePolicy(FailurePolicy)`.

- - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `static <U> FailurePolicy<U>` | `defaultPolicy()` The default policy, which considers an asynchronous result as a failure if `AsyncResult.failed()` returns `true`.
    `boolean` | `test(Future<T> future)` Invoked by the `CircuitBreaker` when an operation completes.

    - ### Methods inherited from interface java.util.function.Predicate

      `and, isEqual, negate, or`

- - ### Method Detail

    - #### defaultPolicy

          static <U> FailurePolicy<U> defaultPolicy()

      The default policy, which considers an asynchronous result as a failure if `AsyncResult.failed()` returns `true`.

    - #### test

          boolean test(Future<T> future)

      Invoked by the `CircuitBreaker` when an operation completes.
      Specified by:
        `test` in interface `java.util.function.Predicate<Future<T>>`
      Parameters:
        `future` - a completed future
      Returns:
        `true` if the asynchronous result should be considered as a failure, `false` otherwise

Copyright © 2025 Eclipse. All rights reserved.