Search in sources :

Example 1 with CircuitBreakerHealthIndicator

use of io.github.resilience4j.circuitbreaker.monitoring.health.CircuitBreakerHealthIndicator in project resilience4j by resilience4j.

the class CircuitBreakerAutoConfiguration method circuitBreakerRegistry.

@Bean
public CircuitBreakerRegistry circuitBreakerRegistry(CircuitBreakerProperties circuitBreakerProperties, EventConsumerRegistry<CircuitBreakerEvent> eventConsumerRegistry, ConfigurableBeanFactory beanFactory) {
    CircuitBreakerRegistry circuitBreakerRegistry = new InMemoryCircuitBreakerRegistry();
    circuitBreakerProperties.getBackends().forEach((name, properties) -> {
        CircuitBreakerConfig circuitBreakerConfig = circuitBreakerProperties.createCircuitBreakerConfig(name);
        CircuitBreaker circuitBreaker = circuitBreakerRegistry.circuitBreaker(name, circuitBreakerConfig);
        circuitBreaker.getEventPublisher().onEvent(eventConsumerRegistry.createEventConsumer(name, properties.getEventConsumerBufferSize()));
        if (properties.getRegisterHealthIndicator()) {
            CircuitBreakerHealthIndicator healthIndicator = new CircuitBreakerHealthIndicator(circuitBreaker);
            beanFactory.registerSingleton(name + "CircuitBreakerHealthIndicator", healthIndicator);
        }
    });
    return circuitBreakerRegistry;
}
Also used : CircuitBreaker(io.github.resilience4j.circuitbreaker.CircuitBreaker) CircuitBreakerHealthIndicator(io.github.resilience4j.circuitbreaker.monitoring.health.CircuitBreakerHealthIndicator) InMemoryCircuitBreakerRegistry(io.github.resilience4j.circuitbreaker.internal.InMemoryCircuitBreakerRegistry) InMemoryCircuitBreakerRegistry(io.github.resilience4j.circuitbreaker.internal.InMemoryCircuitBreakerRegistry) CircuitBreakerRegistry(io.github.resilience4j.circuitbreaker.CircuitBreakerRegistry) CircuitBreakerConfig(io.github.resilience4j.circuitbreaker.CircuitBreakerConfig) Bean(org.springframework.context.annotation.Bean)

Aggregations

CircuitBreaker (io.github.resilience4j.circuitbreaker.CircuitBreaker)1 CircuitBreakerConfig (io.github.resilience4j.circuitbreaker.CircuitBreakerConfig)1 CircuitBreakerRegistry (io.github.resilience4j.circuitbreaker.CircuitBreakerRegistry)1 InMemoryCircuitBreakerRegistry (io.github.resilience4j.circuitbreaker.internal.InMemoryCircuitBreakerRegistry)1 CircuitBreakerHealthIndicator (io.github.resilience4j.circuitbreaker.monitoring.health.CircuitBreakerHealthIndicator)1 Bean (org.springframework.context.annotation.Bean)1