public static AsyncRetryMetrics ofAsyncRetryRegistry(AsyncRetryRegistry retryRegistry) { return new AsyncRetryMetrics(retryRegistry.getAllRetries()); }
public static AsyncRetryMetrics ofAsyncRetryRegistry(String prefix, AsyncRetryRegistry retryRegistry) { return new AsyncRetryMetrics(prefix, retryRegistry.getAllRetries()); }
@Test public void canBuildRetryFromRegistryWithConfigSupplier() { RetryConfig config = RetryConfig.custom().maxAttempts(1000).waitDuration(Duration.ofSeconds(300)).build(); AsyncRetry retry = retryRegistry.retry("testName", () -> config); Assertions.assertThat(retry).isNotNull(); Assertions.assertThat(retryRegistry.getAllRetries()).hasSize(1); }
@Test public void shouldBeTheSameRetry() { AsyncRetry retry = retryRegistry.retry("testName"); AsyncRetry retry2 = retryRegistry.retry("testName"); Assertions.assertThat(retry).isSameAs(retry2); Assertions.assertThat(retryRegistry.getAllRetries()).hasSize(1); }
@Test public void shouldBeNotTheSameRetry() { AsyncRetry retry = retryRegistry.retry("testName"); AsyncRetry retry2 = retryRegistry.retry("otherTestName"); Assertions.assertThat(retry).isNotSameAs(retry2); Assertions.assertThat(retryRegistry.getAllRetries()).hasSize(2); }
@Test public void canBuildRetryFromRegistryWithConfig() { RetryConfig config = RetryConfig.custom().maxAttempts(1000).waitDuration(Duration.ofSeconds(300)).build(); AsyncRetry retry = retryRegistry.retry("testName", config); Assertions.assertThat(retry).isNotNull(); Assertions.assertThat(retryRegistry.getAllRetries()).hasSize(1); }
@Test public void canBuildRetryRegistryWithConfig() { RetryConfig config = RetryConfig.custom().maxAttempts(1000).waitDuration(Duration.ofSeconds(300)).build(); retryRegistry = AsyncRetryRegistry.of(config); AsyncRetry retry = retryRegistry.retry("testName", () -> config); Assertions.assertThat(retry).isNotNull(); Assertions.assertThat(retryRegistry.getAllRetries()).hasSize(1); } }