use of io.github.resilience4j.ratelimiter.internal.InMemoryRateLimiterRegistry in project resilience4j by resilience4j.
the class RateLimiterExportsTest method testConstructors.
@Test
public void testConstructors() {
final RateLimiterRegistry registry = new InMemoryRateLimiterRegistry(RateLimiterConfig.ofDefaults());
RateLimiterExports.ofIterable("boo_limiters", singleton(RateLimiter.ofDefaults("foo")));
RateLimiterExports.ofRateLimiterRegistry("boo_limiters", registry);
RateLimiterExports.ofSupplier("boo_limiters", () -> singleton(RateLimiter.ofDefaults("foo")));
RateLimiterExports.ofIterable(singleton(RateLimiter.ofDefaults("foo")));
RateLimiterExports.ofRateLimiterRegistry(registry);
RateLimiterExports.ofSupplier(() -> singleton(RateLimiter.ofDefaults("foo")));
}
use of io.github.resilience4j.ratelimiter.internal.InMemoryRateLimiterRegistry in project resilience4j by resilience4j.
the class RateLimiterAutoConfiguration method rateLimiterRegistry.
@Bean
public RateLimiterRegistry rateLimiterRegistry(RateLimiterProperties rateLimiterProperties, EventConsumerRegistry<RateLimiterEvent> rateLimiterEventsConsumerRegistry, ConfigurableBeanFactory beanFactory) {
RateLimiterRegistry rateLimiterRegistry = new InMemoryRateLimiterRegistry(RateLimiterConfig.ofDefaults());
rateLimiterProperties.getLimiters().forEach((name, properties) -> {
RateLimiter rateLimiter = createRateLimiter(rateLimiterRegistry, name, properties);
if (properties.getSubscribeForEvents()) {
subscribeToLimiterEvents(rateLimiterEventsConsumerRegistry, name, properties, rateLimiter);
}
if (properties.getRegisterHealthIndicator()) {
createHealthIndicatorForLimiter(beanFactory, name, rateLimiter);
}
});
return rateLimiterRegistry;
}
Aggregations