use of io.github.resilience4j.circuitbreaker.internal.InMemoryCircuitBreakerRegistry 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;
}
use of io.github.resilience4j.circuitbreaker.internal.InMemoryCircuitBreakerRegistry in project resilience4j by resilience4j.
the class CircuitBreakerExportsTest method testConstructors.
@Test
public void testConstructors() {
final CircuitBreakerRegistry registry = new InMemoryCircuitBreakerRegistry();
CircuitBreakerExports.ofIterable("boo_breakers", singleton(CircuitBreaker.ofDefaults("foo")));
CircuitBreakerExports.ofCircuitBreakerRegistry("boo_breakers", registry);
CircuitBreakerExports.ofSupplier("boo_breakers", () -> singleton(CircuitBreaker.ofDefaults("foo")));
CircuitBreakerExports.ofIterable(singleton(CircuitBreaker.ofDefaults("foo")));
CircuitBreakerExports.ofCircuitBreakerRegistry(registry);
CircuitBreakerExports.ofSupplier(() -> singleton(CircuitBreaker.ofDefaults("foo")));
}
Aggregations