Codota Logo
AsyncRetryRegistry
Code IndexAdd Codota to your IDE (free)

How to use
AsyncRetryRegistry
in
io.github.resilience4j.retry

Best Java code snippets using io.github.resilience4j.retry.AsyncRetryRegistry (Showing top 12 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
BufferedReader b =
  • Codota IconInputStream in;new BufferedReader(new InputStreamReader(in))
  • Codota IconReader in;new BufferedReader(in)
  • Codota IconFile file;new BufferedReader(new FileReader(file))
  • Smart code suggestions by Codota
}
origin: resilience4j/resilience4j

@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);
}
origin: resilience4j/resilience4j

@Before
public void setUp() {
  retryRegistry = AsyncRetryRegistry.ofDefaults();
}
origin: resilience4j/resilience4j

@Test
public void shouldUseCustomPrefix() {
  //Given
  AsyncRetryRegistry retryRegistry = AsyncRetryRegistry.ofDefaults();
  AsyncRetry retry = retryRegistry.retry("testName");
  metricRegistry.registerAll(AsyncRetryMetrics.ofAsyncRetryRegistry("testPrefix",retryRegistry));
  // Given the HelloWorldService returns Hello world
  BDDMockito.given(helloWorldService.returnHelloWorld()).willReturn(CompletableFuture.completedFuture("Hello world"));
  String value = awaitResult(retry.executeCompletionStage(scheduler, helloWorldService::returnHelloWorld));
  //Then
  assertThat(value).isEqualTo("Hello world");
  // Then the helloWorldService should be invoked 1 time
  BDDMockito.then(helloWorldService).should(times(1)).returnHelloWorld();
  assertThat(metricRegistry.getMetrics()).hasSize(4);
  assertThat(metricRegistry.getGauges().get("testPrefix.testName." + SUCCESSFUL_CALLS_WITH_RETRY).getValue()).isEqualTo(0L);
  assertThat(metricRegistry.getGauges().get("testPrefix.testName." + SUCCESSFUL_CALLS_WITHOUT_RETRY).getValue()).isEqualTo(1L);
  assertThat(metricRegistry.getGauges().get("testPrefix.testName." + FAILED_CALLS_WITH_RETRY).getValue()).isEqualTo(0L);
  assertThat(metricRegistry.getGauges().get("testPrefix.testName." + FAILED_CALLS_WITHOUT_RETRY).getValue()).isEqualTo(0L);
}
origin: resilience4j/resilience4j

  @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);
  }
}
origin: resilience4j/resilience4j

public static AsyncRetryMetrics ofAsyncRetryRegistry(AsyncRetryRegistry retryRegistry) {
  return new AsyncRetryMetrics(retryRegistry.getAllRetries());
}
origin: resilience4j/resilience4j

@Test
public void shouldReturnTheCorrectName() {
  AsyncRetry retry = retryRegistry.retry("testName");
  Assertions.assertThat(retry).isNotNull();
  Assertions.assertThat(retry.getName()).isEqualTo("testName");
}
origin: resilience4j/resilience4j

@Test
public void shouldRegisterMetricsWithoutRetry() {
  //Given
  AsyncRetryRegistry retryRegistry = AsyncRetryRegistry.ofDefaults();
  AsyncRetry retry = retryRegistry.retry("testName");
  metricRegistry.registerAll(AsyncRetryMetrics.ofAsyncRetryRegistry(retryRegistry));
  // Given the HelloWorldService returns Hello world
  BDDMockito.given(helloWorldService.returnHelloWorld())
   .willReturn(CompletableFuture.completedFuture("Hello world"));
  // Setup circuitbreaker with retry
  String value = awaitResult(retry.executeCompletionStage(scheduler, helloWorldService::returnHelloWorld));
  //Then
  assertThat(value).isEqualTo("Hello world");
  // Then the helloWorldService should be invoked 1 time
  BDDMockito.then(helloWorldService).should(times(1)).returnHelloWorld();
  assertThat(metricRegistry.getMetrics()).hasSize(4);
  assertThat(metricRegistry.getGauges().get("resilience4j.retry.testName." + SUCCESSFUL_CALLS_WITH_RETRY).getValue()).isEqualTo(0L);
  assertThat(metricRegistry.getGauges().get("resilience4j.retry.testName." + SUCCESSFUL_CALLS_WITHOUT_RETRY).getValue()).isEqualTo(1L);
  assertThat(metricRegistry.getGauges().get("resilience4j.retry.testName." + FAILED_CALLS_WITH_RETRY).getValue()).isEqualTo(0L);
  assertThat(metricRegistry.getGauges().get("resilience4j.retry.testName." + FAILED_CALLS_WITHOUT_RETRY).getValue()).isEqualTo(0L);
}
origin: resilience4j/resilience4j

public static AsyncRetryMetrics ofAsyncRetryRegistry(String prefix, AsyncRetryRegistry retryRegistry) {
  return new AsyncRetryMetrics(prefix, retryRegistry.getAllRetries());
}
origin: resilience4j/resilience4j

@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);
}
origin: resilience4j/resilience4j

@Test
public void shouldRegisterMetricsWithRetry() {
  //Given
  AsyncRetryRegistry retryRegistry = AsyncRetryRegistry.ofDefaults();
  AsyncRetry retry = retryRegistry.retry("testName");
  metricRegistry.registerAll(AsyncRetryMetrics.ofAsyncRetryRegistry(retryRegistry));
  // Given the HelloWorldService returns Hello world
  BDDMockito.given(helloWorldService.returnHelloWorld())
      .willReturn(failedFuture(new WebServiceException("BAM!")))
      .willReturn(CompletableFuture.completedFuture("Hello world"))
      .willReturn(failedFuture(new WebServiceException("BAM!")))
      .willReturn(failedFuture(new WebServiceException("BAM!")))
      .willReturn(failedFuture(new WebServiceException("BAM!")));
  // Setup circuitbreaker with retry
  String value1 = awaitResult(retry.executeCompletionStage(scheduler, helloWorldService::returnHelloWorld));
  Try.ofCallable(() -> awaitResult(AsyncRetry.decorateCompletionStage(retry, scheduler, helloWorldService::returnHelloWorld).get()));
  //Then
  assertThat(value1).isEqualTo("Hello world");
  // Then the helloWorldService should be invoked 5 times
  BDDMockito.then(helloWorldService).should(times(5)).returnHelloWorld();
  assertThat(metricRegistry.getMetrics()).hasSize(4);
  assertThat(metricRegistry.getGauges().get("resilience4j.retry.testName." + SUCCESSFUL_CALLS_WITH_RETRY).getValue()).isEqualTo(1L);
  assertThat(metricRegistry.getGauges().get("resilience4j.retry.testName." + SUCCESSFUL_CALLS_WITHOUT_RETRY).getValue()).isEqualTo(0L);
  assertThat(metricRegistry.getGauges().get("resilience4j.retry.testName." + FAILED_CALLS_WITH_RETRY).getValue()).isEqualTo(1L);
  assertThat(metricRegistry.getGauges().get("resilience4j.retry.testName." + FAILED_CALLS_WITHOUT_RETRY).getValue()).isEqualTo(0L);
}
origin: resilience4j/resilience4j

@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);
}
origin: resilience4j/resilience4j

@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);
}
io.github.resilience4j.retryAsyncRetryRegistry

Javadoc

The AsyncRetryRegistry is a factory to create AsyncRetry instances which stores all AsyncRetry instances in a registry.

Most used methods

  • getAllRetries
    Returns all managed AsyncRetry instances.
  • ofDefaults
    Creates an AsyncRetryRegistry with a default Retry configuration.
  • retry
    Returns a managed AsyncRetry or creates a new one with a custom Retry configuration.
  • of
    Creates an AsyncRetryRegistry with a custom Retry configuration.

Popular in Java

  • Making http post requests using okhttp
  • onRequestPermissionsResult (Fragment)
  • getApplicationContext (Context)
  • getSupportFragmentManager (FragmentActivity)
    Return the FragmentManager for interacting with fragments associated with this activity.
  • BufferedImage (java.awt.image)
    The BufferedImage subclass describes an java.awt.Image with an accessible buffer of image data. All
  • BufferedWriter (java.io)
    Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • Timestamp (java.sql)
    A Java representation of the SQL TIMESTAMP type. It provides the capability of representing the SQL
  • JFrame (javax.swing)
  • Runner (org.openjdk.jmh.runner)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now