Interface CircuitBreakerClientHandler

All Known Implementing Classes:
Resilience4JCircuitBreakerClientHandler
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@UnstableApi @FunctionalInterface public interface CircuitBreakerClientHandler
A handler used by a CircuitBreakerClient to integrate with a circuit breaker. One may extend this interface to use a custom circuit breaker with CircuitBreakerClient.

 // using a pre-defined handler
 CircuitBreakerClient.newDecorator(
         CircuitBreakerClientHandler.of(CircuitBreakerMapping.ofDefault()),
         CircuitBreakerRule.onException());


 // defining a custom handler
 CircuitBreakerClient.newDecorator(
         new CircuitBreakerClientHandler() {
             ...
             public CircuitBreakerCallback tryRequest(ClientRequestContext ctx, HttpRequest req) {
                 ...
                 MyCustomCircuitBreaker cb = ...
                 return new CircuitBreakerCallback() {
                     @Override
                     public void onSuccess(RequestContext ctx) {
                         cb.onSuccess();
                     }

                     @Override
                     public void onFailure(RequestContext ctx, @Nullable Throwable throwable) {
                         cb.onFailure();
                     }
                 };
             }
             ...
         },
         CircuitBreakerRule.onException());