Class GrpcCircuitBreakerInterceptor

java.lang.Object
io.micronaut.grpc.client.circuitbreaker.GrpcCircuitBreakerInterceptor
All Implemented Interfaces:
io.grpc.ClientInterceptor

@Internal public final class GrpcCircuitBreakerInterceptor extends Object implements io.grpc.ClientInterceptor
A ClientInterceptor that guards every call of a channel with a Micronaut circuit breaker.

A call that ends with one of the configured failure status codes counts as a failure. After GrpcCircuitBreakerConfiguration.failureThreshold() consecutive failures the circuit opens and calls fail immediately with Status.UNAVAILABLE without reaching the network. After the reset timeout the circuit is half-open: a single trial call is let through, and closes the circuit if it succeeds or opens it again if it fails. Other calls made while the trial is in flight fail fast. The circuit state is updated before the caller is notified of a call's result.

The interceptor never retries. Streaming calls cannot be replayed from an interceptor; configure retries with the gRPC service config instead.

Since:
5.3.0
  • Method Details

    • currentState

      public io.micronaut.retry.CircuitState currentState()
      Returns:
      The current state of the circuit
    • interceptCall

      public <ReqT,RespT> io.grpc.ClientCall<ReqT,RespT> interceptCall(io.grpc.MethodDescriptor<ReqT,RespT> method, io.grpc.CallOptions callOptions, io.grpc.Channel next)
      Specified by:
      interceptCall in interface io.grpc.ClientInterceptor