io.github.resilience4j.ratelimiter.RateLimiterRegistry Java Examples

The following examples show how to use io.github.resilience4j.ratelimiter.RateLimiterRegistry. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TaggedRateLimiterMetricsTest.java    From resilience4j with Apache License 2.0 6 votes vote down vote up
@Test
public void customMetricNamesGetApplied() {
    MeterRegistry meterRegistry = new SimpleMeterRegistry();
    RateLimiterRegistry rateLimiterRegistry = RateLimiterRegistry.ofDefaults();
    rateLimiterRegistry.rateLimiter("backendA");
    TaggedRateLimiterMetrics.ofRateLimiterRegistry(
        RateLimiterMetricNames.custom()
            .availablePermissionsMetricName("custom_available_permissions")
            .waitingThreadsMetricName("custom_waiting_threads")
            .build(),
        rateLimiterRegistry
    ).bindTo(meterRegistry);

    Set<String> metricNames = meterRegistry.getMeters()
        .stream()
        .map(Meter::getId)
        .map(Meter.Id::getName)
        .collect(Collectors.toSet());

    assertThat(metricNames).hasSameElementsAs(Arrays.asList(
        "custom_available_permissions",
        "custom_waiting_threads"
    ));
}
 
Example #2
Source File: TaggedRateLimiterMetricsPublisherTest.java    From resilience4j with Apache License 2.0 6 votes vote down vote up
@Test
public void customMetricNamesGetApplied() {
    MeterRegistry meterRegistry = new SimpleMeterRegistry();
    TaggedRateLimiterMetricsPublisher taggedRateLimiterMetricsPublisher = new TaggedRateLimiterMetricsPublisher(
        RateLimiterMetricNames.custom()
            .availablePermissionsMetricName("custom_available_permissions")
            .waitingThreadsMetricName("custom_waiting_threads")
            .build(), meterRegistry);

    RateLimiterRegistry rateLimiterRegistry = RateLimiterRegistry
        .of(RateLimiterConfig.ofDefaults(), taggedRateLimiterMetricsPublisher);
    rateLimiterRegistry.rateLimiter("backendA");

    Set<String> metricNames = meterRegistry.getMeters()
        .stream()
        .map(Meter::getId)
        .map(Meter.Id::getName)
        .collect(Collectors.toSet());

    assertThat(metricNames).hasSameElementsAs(Arrays.asList(
        "custom_available_permissions",
        "custom_waiting_threads"
    ));
}
 
Example #3
Source File: InMemoryRateLimiterRegistryTest.java    From resilience4j with Apache License 2.0 6 votes vote down vote up
@Test
@SuppressWarnings("unchecked")
public void rateLimiterPositiveWithSupplier() throws Exception {
    RateLimiterRegistry registry = new InMemoryRateLimiterRegistry(config);
    Supplier<RateLimiterConfig> rateLimiterConfigSupplier = mock(Supplier.class);
    when(rateLimiterConfigSupplier.get())
        .thenReturn(config);

    RateLimiter firstRateLimiter = registry.rateLimiter("test", rateLimiterConfigSupplier);
    verify(rateLimiterConfigSupplier, times(1)).get();
    RateLimiter sameAsFirst = registry.rateLimiter("test", rateLimiterConfigSupplier);
    verify(rateLimiterConfigSupplier, times(1)).get();
    RateLimiter anotherLimit = registry.rateLimiter("test1", rateLimiterConfigSupplier);
    verify(rateLimiterConfigSupplier, times(2)).get();

    then(firstRateLimiter).isEqualTo(sameAsFirst);
    then(firstRateLimiter).isNotEqualTo(anotherLimit);
}
 
Example #4
Source File: BackendBController.java    From resilience4j-spring-boot2-demo with Apache License 2.0 6 votes vote down vote up
public BackendBController(
        @Qualifier("backendBService")Service businessBService,
        CircuitBreakerRegistry circuitBreakerRegistry,
        ThreadPoolBulkheadRegistry threadPoolBulkheadRegistry,
        BulkheadRegistry bulkheadRegistry,
        RetryRegistry retryRegistry,
        RateLimiterRegistry rateLimiterRegistry,
        TimeLimiterRegistry timeLimiterRegistry){
    this.businessBService = businessBService;
    this.circuitBreaker = circuitBreakerRegistry.circuitBreaker(BACKEND_B);
    this.bulkhead = bulkheadRegistry.bulkhead(BACKEND_B);
    this.threadPoolBulkhead = threadPoolBulkheadRegistry.bulkhead(BACKEND_B);
    this.retry = retryRegistry.retry(BACKEND_B);
    this.rateLimiter = rateLimiterRegistry.rateLimiter(BACKEND_B);
    this.timeLimiter = timeLimiterRegistry.timeLimiter(BACKEND_B);
    this.scheduledExecutorService = Executors.newScheduledThreadPool(3);
}
 
Example #5
Source File: RateLimiterConfigurationOnMissingBeanTest.java    From resilience4j with Apache License 2.0 6 votes vote down vote up
@Bean
public RateLimiterAspect rateLimiterAspect(
    RateLimiterRegistry rateLimiterRegistry,
    @Autowired(required = false) List<RateLimiterAspectExt> rateLimiterAspectExtList,
    FallbackDecorators fallbackDecorators,
    SpelResolver spelResolver
) {
    rateLimiterAspect = new RateLimiterAspect(
        rateLimiterRegistry,
        new RateLimiterConfigurationProperties(),
        rateLimiterAspectExtList,
        fallbackDecorators,
        spelResolver
    );
    return rateLimiterAspect;
}
 
Example #6
Source File: SpringBootCommonTest.java    From resilience4j with Apache License 2.0 6 votes vote down vote up
@Test
public void testRateLimiterCommonConfig() {
    RateLimiterConfigurationOnMissingBean rateLimiterConfigurationOnMissingBean = new RateLimiterConfigurationOnMissingBean();
    assertThat(rateLimiterConfigurationOnMissingBean.reactorRateLimiterAspectExt()).isNotNull();
    assertThat(rateLimiterConfigurationOnMissingBean.rxJava2RateLimiterAspectExt()).isNotNull();
    assertThat(rateLimiterConfigurationOnMissingBean
        .rateLimiterRegistry(new RateLimiterConfigurationProperties(),
            new DefaultEventConsumerRegistry<>(),
            new CompositeRegistryEventConsumer<>(Collections.emptyList()),
            new CompositeCustomizer<>(Collections.emptyList()))).isNotNull();
    assertThat(rateLimiterConfigurationOnMissingBean
        .rateLimiterAspect(new RateLimiterConfigurationProperties(),
            RateLimiterRegistry.ofDefaults(), Collections.emptyList(),
            new FallbackDecorators(Arrays.asList(new CompletionStageFallbackDecorator())),
            new SpelResolver(new SpelExpressionParser(), new StandardReflectionParameterNameDiscoverer()))).isNotNull();
    assertThat(rateLimiterConfigurationOnMissingBean
        .rateLimiterRegistryEventConsumer(Optional.empty())).isNotNull();
}
 
Example #7
Source File: RateLimitersHealthIndicatorAutoConfiguration.java    From resilience4j with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean(name = "rateLimitersHealthIndicator")
@ConditionalOnProperty(prefix = "management.health.ratelimiters", name = "enabled")
public RateLimitersHealthIndicator rateLimitersHealthIndicator(
    RateLimiterRegistry rateLimiterRegistry,
    RateLimiterConfigurationProperties rateLimiterProperties,
    StatusAggregator statusAggregator) {
    return new RateLimitersHealthIndicator(rateLimiterRegistry, rateLimiterProperties, statusAggregator);
}
 
Example #8
Source File: Resilience4jModule.java    From resilience4j with Apache License 2.0 5 votes vote down vote up
@Override
public RateLimiterRegistry get() {
    // build configs
    RateLimiterConfigurationProperties rateLimiterProperties = resilience4jConfig
        .getRatelimiter();
    Map<String, RateLimiterConfig> configs = rateLimiterProperties.getConfigs()
        .entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey,
            entry -> rateLimiterProperties.createRateLimiterConfig(entry.getValue(),
                new CompositeCustomizer<RateLimiterConfigCustomizer>(
                    Collections.emptyList()),
                entry.getKey())));
    RateLimiterRegistry rateLimiterRegistry = RateLimiterRegistry.of(configs);

    // build ratelimiters
    EndpointsConfig endpointsConfig = resilience4jConfig.getEndpoints();
    rateLimiterProperties.getInstances().forEach((name, rateLimiterConfig) -> {
        io.github.resilience4j.ratelimiter.RateLimiter rateLimiter =
            rateLimiterRegistry.rateLimiter(name,
                rateLimiterProperties.createRateLimiterConfig(rateLimiterConfig,
                    new CompositeCustomizer<>(Collections.emptyList()), name));
        if (endpointsConfig.getRatelimiter().isEnabled()) {
            rateLimiter.getEventPublisher().onEvent(eventConsumerRegistry
                .createEventConsumer(name,
                    rateLimiterConfig.getEventConsumerBufferSize() != null
                        ? rateLimiterConfig.getEventConsumerBufferSize() : 100));
        }
    });

    return rateLimiterRegistry;
}
 
Example #9
Source File: RateLimiterConfiguration.java    From resilience4j with Apache License 2.0 5 votes vote down vote up
/**
 * Registers the post creation consumer function that registers the consumer events to the rate
 * limiters.
 *
 * @param rateLimiterRegistry   The rate limiter registry.
 * @param eventConsumerRegistry The event consumer registry.
 */
private void registerEventConsumer(RateLimiterRegistry rateLimiterRegistry,
    EventConsumerRegistry<RateLimiterEvent> eventConsumerRegistry,
    RateLimiterConfigurationProperties rateLimiterConfigurationProperties) {
    rateLimiterRegistry.getEventPublisher().onEntryAdded(
        event -> registerEventConsumer(eventConsumerRegistry, event.getAddedEntry(),
            rateLimiterConfigurationProperties));
}
 
Example #10
Source File: RateLimiterConfiguration.java    From resilience4j with Apache License 2.0 5 votes vote down vote up
@Bean
@Conditional(value = {AspectJOnClasspathCondition.class})
public RateLimiterAspect rateLimiterAspect(
    RateLimiterConfigurationProperties rateLimiterProperties,
    RateLimiterRegistry rateLimiterRegistry,
    @Autowired(required = false) List<RateLimiterAspectExt> rateLimiterAspectExtList,
    FallbackDecorators fallbackDecorators,
    SpelResolver spelResolver
) {
    return new RateLimiterAspect(rateLimiterRegistry, rateLimiterProperties,
        rateLimiterAspectExtList, fallbackDecorators, spelResolver);
}
 
Example #11
Source File: RateLimiterAspect.java    From resilience4j with Apache License 2.0 5 votes vote down vote up
public RateLimiterAspect(RateLimiterRegistry rateLimiterRegistry,
                         RateLimiterConfigurationProperties properties,
                         @Autowired(required = false) List<RateLimiterAspectExt> rateLimiterAspectExtList,
                         FallbackDecorators fallbackDecorators,
                         SpelResolver spelResolver) {
    this.rateLimiterRegistry = rateLimiterRegistry;
    this.properties = properties;
    this.rateLimiterAspectExtList = rateLimiterAspectExtList;
    this.fallbackDecorators = fallbackDecorators;
    this.spelResolver = spelResolver;
}
 
Example #12
Source File: RateLimiterConfigurationTest.java    From resilience4j with Apache License 2.0 5 votes vote down vote up
@Test
public void testRateLimiterRegistry() {
    io.github.resilience4j.common.ratelimiter.configuration.RateLimiterConfigurationProperties.InstanceProperties instanceProperties1 = new io.github.resilience4j.common.ratelimiter.configuration.RateLimiterConfigurationProperties.InstanceProperties();
    instanceProperties1.setLimitForPeriod(2);
    instanceProperties1.setSubscribeForEvents(true);
    io.github.resilience4j.common.ratelimiter.configuration.RateLimiterConfigurationProperties.InstanceProperties instanceProperties2 = new io.github.resilience4j.common.ratelimiter.configuration.RateLimiterConfigurationProperties.InstanceProperties();
    instanceProperties2.setLimitForPeriod(4);
    instanceProperties2.setSubscribeForEvents(true);
    RateLimiterConfigurationProperties rateLimiterConfigurationProperties = new RateLimiterConfigurationProperties();
    rateLimiterConfigurationProperties.getInstances().put("backend1", instanceProperties1);
    rateLimiterConfigurationProperties.getInstances().put("backend2", instanceProperties2);
    rateLimiterConfigurationProperties.setRateLimiterAspectOrder(300);
    RateLimiterConfiguration rateLimiterConfiguration = new RateLimiterConfiguration();
    DefaultEventConsumerRegistry<RateLimiterEvent> eventConsumerRegistry = new DefaultEventConsumerRegistry<>();

    RateLimiterRegistry rateLimiterRegistry = rateLimiterConfiguration
        .rateLimiterRegistry(rateLimiterConfigurationProperties, eventConsumerRegistry,
            new CompositeRegistryEventConsumer<>(emptyList()),
            compositeRateLimiterCustomizerTest());

    assertThat(rateLimiterConfigurationProperties.getRateLimiterAspectOrder()).isEqualTo(300);
    assertThat(rateLimiterRegistry.getAllRateLimiters().size()).isEqualTo(2);
    RateLimiter rateLimiter = rateLimiterRegistry.rateLimiter("backend1");
    assertThat(rateLimiter).isNotNull();
    assertThat(rateLimiter.getRateLimiterConfig().getLimitForPeriod()).isEqualTo(2);
    RateLimiter rateLimiter2 = rateLimiterRegistry.rateLimiter("backend2");
    assertThat(rateLimiter2).isNotNull();
    assertThat(rateLimiter2.getRateLimiterConfig().getLimitForPeriod()).isEqualTo(4);
    assertThat(eventConsumerRegistry.getAllEventConsumer()).hasSize(2);
}
 
Example #13
Source File: RateLimiterConfigurationSpringTest.java    From resilience4j with Apache License 2.0 5 votes vote down vote up
@Bean
public RateLimiterAspect rateLimiterAspect(
    RateLimiterRegistry rateLimiterRegistry,
    @Autowired(required = false) List<RateLimiterAspectExt> rateLimiterAspectExts,
    FallbackDecorators recoveryDecorators,
    SpelResolver spelResolver
) {
    rateLimiterAspect = new RateLimiterAspect(rateLimiterRegistry,
        rateLimiterConfigurationProperties(), rateLimiterAspectExts, recoveryDecorators, spelResolver);
    return rateLimiterAspect;
}
 
Example #14
Source File: RateLimitersHealthIndicator.java    From resilience4j with Apache License 2.0 5 votes vote down vote up
public RateLimitersHealthIndicator(RateLimiterRegistry rateLimiterRegistry,
    RateLimiterConfigurationProperties rateLimiterProperties,
    StatusAggregator statusAggregator) {
    this.rateLimiterRegistry = rateLimiterRegistry;
    this.rateLimiterProperties = rateLimiterProperties;
    this.statusAggregator = statusAggregator;
}
 
Example #15
Source File: RateLimiterConfiguration.java    From resilience4j with Apache License 2.0 5 votes vote down vote up
/**
 * Initializes a rate limiter registry.
 *
 * @param rateLimiterConfigurationProperties The rate limiter configuration properties.
 * @param compositeRateLimiterCustomizer the composite rate limiter customizer delegate
 * @return a RateLimiterRegistry
 */
private RateLimiterRegistry createRateLimiterRegistry(
    RateLimiterConfigurationProperties rateLimiterConfigurationProperties,
    RegistryEventConsumer<RateLimiter> rateLimiterRegistryEventConsumer,
    CompositeCustomizer<RateLimiterConfigCustomizer> compositeRateLimiterCustomizer) {
    Map<String, RateLimiterConfig> configs = rateLimiterConfigurationProperties.getConfigs()
        .entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey,
            entry -> rateLimiterConfigurationProperties
                .createRateLimiterConfig(entry.getValue(), compositeRateLimiterCustomizer,
                    entry.getKey())));

    return RateLimiterRegistry.of(configs, rateLimiterRegistryEventConsumer,
        io.vavr.collection.HashMap.ofAll(rateLimiterConfigurationProperties.getTags()));
}
 
Example #16
Source File: RateLimiterMetricsAutoConfiguration.java    From resilience4j with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnProperty(value = "resilience4j.ratelimiter.metrics.legacy.enabled", havingValue = "true")
@ConditionalOnMissingBean
public TaggedRateLimiterMetrics registerRateLimiterMetrics(
    RateLimiterRegistry rateLimiterRegistry) {
    return TaggedRateLimiterMetrics.ofRateLimiterRegistry(rateLimiterRegistry);
}
 
Example #17
Source File: AbstractRateLimiterConfigurationOnMissingBean.java    From resilience4j with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean
public RateLimiterRegistry rateLimiterRegistry(
    RateLimiterConfigurationProperties rateLimiterProperties,
    EventConsumerRegistry<RateLimiterEvent> rateLimiterEventsConsumerRegistry,
    RegistryEventConsumer<RateLimiter> rateLimiterRegistryEventConsumer,
    @Qualifier("compositeRateLimiterCustomizer") CompositeCustomizer<RateLimiterConfigCustomizer> compositeRateLimiterCustomizer) {
    return rateLimiterConfiguration
        .rateLimiterRegistry(rateLimiterProperties, rateLimiterEventsConsumerRegistry,
            rateLimiterRegistryEventConsumer, compositeRateLimiterCustomizer);
}
 
Example #18
Source File: AbstractRateLimiterConfigurationOnMissingBean.java    From resilience4j with Apache License 2.0 5 votes vote down vote up
@Bean
@Conditional(value = {AspectJOnClasspathCondition.class})
@ConditionalOnMissingBean
public RateLimiterAspect rateLimiterAspect(
    RateLimiterConfigurationProperties rateLimiterProperties,
    RateLimiterRegistry rateLimiterRegistry,
    @Autowired(required = false) List<RateLimiterAspectExt> rateLimiterAspectExtList,
    FallbackDecorators fallbackDecorators,
    SpelResolver spelResolver
) {
    return rateLimiterConfiguration
        .rateLimiterAspect(rateLimiterProperties, rateLimiterRegistry, rateLimiterAspectExtList,
            fallbackDecorators, spelResolver);
}
 
Example #19
Source File: RateLimiterMetricsTest.java    From resilience4j with Apache License 2.0 5 votes vote down vote up
@Override
protected RateLimiter givenMetricRegistry(String prefix, MetricRegistry metricRegistry) {
    RateLimiterRegistry rateLimiterRegistry = RateLimiterRegistry.ofDefaults();
    RateLimiter rateLimiter = rateLimiterRegistry.rateLimiter("testLimit");
    metricRegistry.registerAll(
        RateLimiterMetrics.ofIterable(prefix, rateLimiterRegistry.getAllRateLimiters()));

    return rateLimiter;
}
 
Example #20
Source File: RateLimiterMetricsTest.java    From resilience4j with Apache License 2.0 5 votes vote down vote up
@Override
protected RateLimiter givenMetricRegistry(MetricRegistry metricRegistry) {
    RateLimiterRegistry rateLimiterRegistry = RateLimiterRegistry.ofDefaults();
    RateLimiter rateLimiter = rateLimiterRegistry.rateLimiter("testLimit");
    metricRegistry.registerAll(RateLimiterMetrics.ofRateLimiterRegistry(rateLimiterRegistry));

    return rateLimiter;
}
 
Example #21
Source File: RateLimiterMetricsPublisherTest.java    From resilience4j with Apache License 2.0 5 votes vote down vote up
@Override
protected RateLimiter givenMetricRegistry(String prefix, MetricRegistry metricRegistry) {
    RateLimiterRegistry rateLimiterRegistry =
        RateLimiterRegistry.of(RateLimiterConfig.ofDefaults(),
            new RateLimiterMetricsPublisher(prefix, metricRegistry));

    return rateLimiterRegistry.rateLimiter("testLimit");
}
 
Example #22
Source File: RateLimiterMetricsPublisherTest.java    From resilience4j with Apache License 2.0 5 votes vote down vote up
@Override
protected RateLimiter givenMetricRegistry(MetricRegistry metricRegistry) {
    RateLimiterRegistry rateLimiterRegistry =
        RateLimiterRegistry.of(RateLimiterConfig.ofDefaults(),
            new RateLimiterMetricsPublisher(metricRegistry));

    return rateLimiterRegistry.rateLimiter("testLimit");
}
 
Example #23
Source File: InMemoryRateLimiterRegistryTest.java    From resilience4j with Apache License 2.0 5 votes vote down vote up
@Test
public void rateLimiterGetAllRateLimiters() {
    RateLimiterRegistry registry = new InMemoryRateLimiterRegistry(config);
    registry.rateLimiter("foo");

    assertThat(registry.getAllRateLimiters().size()).isEqualTo(1);
    assertThat(registry.getAllRateLimiters().get(0).getName()).isEqualTo("foo");
}
 
Example #24
Source File: CommonRateLimiter.java    From charon-spring-boot-starter with Apache License 2.0 5 votes vote down vote up
TaggedRateLimiterMetrics createMetrics(RateLimiterRegistry registry, String mappingName) {
    String availablePermissionsMetricName = metricName(mappingName, RATE_LIMITING_METRICS_NAME, "available-permissions");
    String waitingThreadsMetricName = metricName(mappingName, RATE_LIMITING_METRICS_NAME, "waiting-threads");
    TaggedRateLimiterMetrics.MetricNames metricNames = TaggedRateLimiterMetrics.MetricNames.custom()
            .availablePermissionsMetricName(availablePermissionsMetricName)
            .waitingThreadsMetricName(waitingThreadsMetricName)
            .build();
    return ofRateLimiterRegistry(metricNames, registry);
}
 
Example #25
Source File: RefreshScopedRateLimiterAutoConfiguration.java    From resilience4j with Apache License 2.0 5 votes vote down vote up
/**
 * @param rateLimiterProperties             ratelimiter spring configuration properties
 * @param rateLimiterEventsConsumerRegistry the ratelimiter event consumer registry
 * @return the RefreshScoped RateLimiterRegistry
 */
@Bean
@org.springframework.cloud.context.config.annotation.RefreshScope
@ConditionalOnMissingBean
public RateLimiterRegistry rateLimiterRegistry(
    RateLimiterConfigurationProperties rateLimiterProperties,
    EventConsumerRegistry<RateLimiterEvent> rateLimiterEventsConsumerRegistry,
    RegistryEventConsumer<RateLimiter> rateLimiterRegistryEventConsumer,
    @Qualifier("compositeRateLimiterCustomizer") CompositeCustomizer<RateLimiterConfigCustomizer> compositeRateLimiterCustomizer) {
    return rateLimiterConfiguration.rateLimiterRegistry(
        rateLimiterProperties, rateLimiterEventsConsumerRegistry,
        rateLimiterRegistryEventConsumer, compositeRateLimiterCustomizer);
}
 
Example #26
Source File: InMemoryRateLimiterRegistryTest.java    From resilience4j with Apache License 2.0 5 votes vote down vote up
@Test
public void rateLimiterPositive() throws Exception {
    RateLimiterRegistry registry = RateLimiterRegistry.of(config);
    RateLimiter firstRateLimiter = registry.rateLimiter("test");
    RateLimiter anotherLimit = registry.rateLimiter("test1");
    RateLimiter sameAsFirst = registry.rateLimiter("test");

    then(firstRateLimiter).isEqualTo(sameAsFirst);
    then(firstRateLimiter).isNotEqualTo(anotherLimit);
}
 
Example #27
Source File: InMemoryRateLimiterRegistryTest.java    From resilience4j with Apache License 2.0 5 votes vote down vote up
@Test
public void rateLimiterNewWithNullName() throws Exception {
    exception.expect(NullPointerException.class);
    exception.expectMessage(NAME_MUST_NOT_BE_NULL);
    RateLimiterRegistry registry = new InMemoryRateLimiterRegistry(config);
    registry.rateLimiter(null);
}
 
Example #28
Source File: InMemoryRateLimiterRegistryTest.java    From resilience4j with Apache License 2.0 5 votes vote down vote up
@Test
public void rateLimiterNewWithNullNonDefaultConfig() throws Exception {
    exception.expect(NullPointerException.class);
    exception.expectMessage(CONFIG_MUST_NOT_BE_NULL);
    RateLimiterRegistry registry = new InMemoryRateLimiterRegistry(config);
    RateLimiterConfig rateLimiterConfig = null;
    registry.rateLimiter("name", rateLimiterConfig);
}
 
Example #29
Source File: InMemoryRateLimiterRegistryTest.java    From resilience4j with Apache License 2.0 5 votes vote down vote up
@Test
public void rateLimiterNewWithNullNameAndNonDefaultConfig() throws Exception {
    exception.expect(NullPointerException.class);
    exception.expectMessage(NAME_MUST_NOT_BE_NULL);
    RateLimiterRegistry registry = new InMemoryRateLimiterRegistry(config);
    registry.rateLimiter(null, config);
}
 
Example #30
Source File: InMemoryRateLimiterRegistryTest.java    From resilience4j with Apache License 2.0 5 votes vote down vote up
@Test
public void rateLimiterNewWithNullNameAndConfigSupplier() throws Exception {
    exception.expect(NullPointerException.class);
    exception.expectMessage(NAME_MUST_NOT_BE_NULL);
    RateLimiterRegistry registry = new InMemoryRateLimiterRegistry(config);
    registry.rateLimiter(null, () -> config);
}