use of io.github.resilience4j.timelimiter.TimeLimiterRegistry in project resilience4j by resilience4j.
the class TimeLimiterMetricsTest method given.
@Override
protected TimeLimiter given(String prefix, MetricRegistry metricRegistry) {
TimeLimiterRegistry timeLimiterRegistry = TimeLimiterRegistry.ofDefaults();
TimeLimiter timeLimiter = timeLimiterRegistry.timeLimiter("testLimit");
metricRegistry.registerAll(TimeLimiterMetrics.ofTimeLimiterRegistry(prefix, timeLimiterRegistry));
return timeLimiter;
}
use of io.github.resilience4j.timelimiter.TimeLimiterRegistry in project resilience4j by resilience4j.
the class TaggedTimeLimiterMetricsTest method customMetricNamesGetApplied.
@Test
public void customMetricNamesGetApplied() {
MeterRegistry meterRegistry = new SimpleMeterRegistry();
TimeLimiterRegistry timeLimiterRegistry = TimeLimiterRegistry.ofDefaults();
timeLimiterRegistry.timeLimiter("backendA");
TaggedTimeLimiterMetrics.ofTimeLimiterRegistry(TimeLimiterMetricNames.custom().callsMetricName("custom_calls").build(), timeLimiterRegistry).bindTo(meterRegistry);
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 TimeLimiterConfiguration method timeLimiterRegistry.
@Bean
public TimeLimiterRegistry timeLimiterRegistry(TimeLimiterConfigurationProperties timeLimiterConfigurationProperties, EventConsumerRegistry<TimeLimiterEvent> timeLimiterEventConsumerRegistry, RegistryEventConsumer<TimeLimiter> timeLimiterRegistryEventConsumer, @Qualifier("compositeTimeLimiterCustomizer") CompositeCustomizer<TimeLimiterConfigCustomizer> compositeTimeLimiterCustomizer) {
TimeLimiterRegistry timeLimiterRegistry = createTimeLimiterRegistry(timeLimiterConfigurationProperties, timeLimiterRegistryEventConsumer, compositeTimeLimiterCustomizer);
registerEventConsumer(timeLimiterRegistry, timeLimiterEventConsumerRegistry, timeLimiterConfigurationProperties);
initTimeLimiterRegistry(timeLimiterRegistry, timeLimiterConfigurationProperties, compositeTimeLimiterCustomizer);
return timeLimiterRegistry;
}
use of io.github.resilience4j.timelimiter.TimeLimiterRegistry in project resilience4j by resilience4j.
the class InMemoryTimeLimiterRegistryTest method timeLimiterPositive.
@Test
public void timeLimiterPositive() {
TimeLimiterRegistry registry = TimeLimiterRegistry.of(config);
TimeLimiter firstTimeLimiter = registry.timeLimiter("test");
TimeLimiter anotherLimit = registry.timeLimiter("test1");
TimeLimiter sameAsFirst = registry.timeLimiter("test");
then(firstTimeLimiter).isEqualTo(sameAsFirst);
then(firstTimeLimiter).isNotEqualTo(anotherLimit);
}
use of io.github.resilience4j.timelimiter.TimeLimiterRegistry in project resilience4j by resilience4j.
the class InMemoryTimeLimiterRegistryTest method timeLimiterNewWithNullNameAndConfigSupplier.
@Test
public void timeLimiterNewWithNullNameAndConfigSupplier() {
exception.expect(NullPointerException.class);
exception.expectMessage(NAME_MUST_NOT_BE_NULL);
TimeLimiterRegistry registry = new InMemoryTimeLimiterRegistry(config);
registry.timeLimiter(null, () -> config);
}
Aggregations