Class GrpcCircuitBreakerRegistry

java.lang.Object
io.micronaut.grpc.client.circuitbreaker.GrpcCircuitBreakerRegistry

@Singleton @Requires(classes=io.micronaut.retry.CircuitBreakerOperationsFactory.class) public class GrpcCircuitBreakerRegistry extends Object
Holds one circuit breaker per gRPC channel that enables grpc.channels.<name>.circuit-breaker.enabled. All stubs created from the same channel share its circuit breaker.

Requires io.micronaut:micronaut-retry on the classpath.

Since:
5.3.0
  • Constructor Details

    • GrpcCircuitBreakerRegistry

      public GrpcCircuitBreakerRegistry(io.micronaut.context.ApplicationContext context, io.micronaut.retry.CircuitBreakerOperationsFactory operationsFactory, @Named("io") ExecutorService ioExecutor)
      Parameters:
      context - The application context
      operationsFactory - The factory for circuit breaker operations
      ioExecutor - The executor that runs the callbacks of rejected calls when neither the call nor the channel configuration specifies one
  • Method Details

    • findInterceptor

      public Optional<io.grpc.ClientInterceptor> findInterceptor(String channelName)
      Returns the circuit breaker interceptor of a channel, if its circuit breaker is enabled.
      Parameters:
      channelName - The channel name
      Returns:
      The interceptor
    • currentState

      public Optional<io.micronaut.retry.CircuitState> currentState(String channelName)
      Returns the state of a channel's circuit breaker.
      Parameters:
      channelName - The channel name
      Returns:
      The state, or empty if the channel has no circuit breaker