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

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

Best Java code snippets using io.github.resilience4j.retry.AsyncRetryRegistry.ofDefaults (Showing top 4 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

@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 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

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

Javadoc

Creates an AsyncRetryRegistry with a default Retry configuration.

Popular methods of AsyncRetryRegistry

  • getAllRetries
    Returns all managed AsyncRetry instances.
  • 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

  • Start an intent from android
  • startActivity (Activity)
  • onCreateOptionsMenu (Activity)
  • findViewById (Activity)
  • Container (java.awt)
    A generic Abstract Window Toolkit(AWT) container object is a component that can contain other AWT co
  • Menu (java.awt)
  • URI (java.net)
    Represents a Uniform Resource Identifier (URI) reference. Aside from some minor deviations noted bel
  • ResultSet (java.sql)
    An interface for an object which represents a database table entry, returned as the result of the qu
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • JFileChooser (javax.swing)
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