use of io.github.resilience4j.timelimiter.TimeLimiterRegistry in project resilience4j by resilience4j.
the class TimeLimiterMetricsTest method given.
@Override
protected TimeLimiter given(MetricRegistry metricRegistry) {
TimeLimiterRegistry timeLimiterRegistry = TimeLimiterRegistry.ofDefaults();
TimeLimiter timeLimiter = timeLimiterRegistry.timeLimiter("testLimit");
metricRegistry.registerAll(TimeLimiterMetrics.ofTimeLimiterRegistry(timeLimiterRegistry));
return timeLimiter;
}
use of io.github.resilience4j.timelimiter.TimeLimiterRegistry in project resilience4j by resilience4j.
the class TaggedTimeLimiterMetricsPublisherTest method customMetricNamesGetApplied.
@Test
public void customMetricNamesGetApplied() {
MeterRegistry meterRegistry = new SimpleMeterRegistry();
TaggedTimeLimiterMetricsPublisher taggedTimeLimiterMetricsPublisher = new TaggedTimeLimiterMetricsPublisher(TimeLimiterMetricNames.custom().callsMetricName("custom_calls").build(), meterRegistry);
TimeLimiterRegistry timeLimiterRegistry = TimeLimiterRegistry.of(TimeLimiterConfig.ofDefaults(), taggedTimeLimiterMetricsPublisher);
timeLimiterRegistry.timeLimiter("backendA");
Set<String> metricNames = meterRegistry.getMeters().stream().map(Meter::getId).map(Meter.Id::getName).collect(Collectors.toSet());
assertThat(metricNames).hasSameElementsAs(Arrays.asList("custom_calls"));
}
use of io.github.resilience4j.timelimiter.TimeLimiterRegistry in project resilience4j by resilience4j.
the class InMemoryTimeLimiterRegistryTest method timeLimiterPositiveWithSupplier.
@Test
@SuppressWarnings("unchecked")
public void timeLimiterPositiveWithSupplier() {
TimeLimiterRegistry registry = new InMemoryTimeLimiterRegistry(config);
Supplier<TimeLimiterConfig> timeLimiterConfigSupplier = mock(Supplier.class);
given(timeLimiterConfigSupplier.get()).willReturn(config);
TimeLimiter firstTimeLimiter = registry.timeLimiter("test", timeLimiterConfigSupplier);
verify(timeLimiterConfigSupplier, times(1)).get();
TimeLimiter sameAsFirst = registry.timeLimiter("test", timeLimiterConfigSupplier);
verify(timeLimiterConfigSupplier, times(1)).get();
TimeLimiter anotherLimit = registry.timeLimiter("test1", timeLimiterConfigSupplier);
verify(timeLimiterConfigSupplier, times(2)).get();
then(firstTimeLimiter).isEqualTo(sameAsFirst);
then(firstTimeLimiter).isNotEqualTo(anotherLimit);
}
use of io.github.resilience4j.timelimiter.TimeLimiterRegistry in project resilience4j by resilience4j.
the class InMemoryTimeLimiterRegistryTest method timeLimiterNewWithNullNameAndNonDefaultConfig.
@Test
public void timeLimiterNewWithNullNameAndNonDefaultConfig() {
exception.expect(NullPointerException.class);
exception.expectMessage(NAME_MUST_NOT_BE_NULL);
TimeLimiterRegistry registry = new InMemoryTimeLimiterRegistry(config);
registry.timeLimiter(null, config);
}
use of io.github.resilience4j.timelimiter.TimeLimiterRegistry in project resilience4j by resilience4j.
the class InMemoryTimeLimiterRegistryTest method timeLimiterNewWithNullName.
@Test
public void timeLimiterNewWithNullName() {
exception.expect(NullPointerException.class);
exception.expectMessage(NAME_MUST_NOT_BE_NULL);
TimeLimiterRegistry registry = new InMemoryTimeLimiterRegistry(config);
registry.timeLimiter(null);
}
Aggregations