Class DmxRetry
java.lang.Object
dmx.fun.resilience4j.DmxRetry
dmx-fun adapter for Resilience4J
Retry.
Executes a supplier through the configured retry policy and returns a dmx-fun type instead of throwing. Configure the retry using the native Resilience4J API:
RetryConfig config = RetryConfig.custom()
.maxAttempts(3)
.waitDuration(Duration.ofMillis(200))
.retryOnException(IOException.class::isInstance)
.build();
DmxRetry retry = DmxRetry.of("my-retry", config);
Try<Response> r1 = retry.executeTry(() -> httpClient.get(url));
Result<Response, Throwable> r2 = retry.executeResult(() -> httpClient.get(url));
-
Method Summary
Modifier and TypeMethodDescriptionexecuteResult(CheckedSupplier<V> supplier) Executes the supplier through the retry policy.<V> Try<V> executeTry(CheckedSupplier<V> supplier) Executes the supplier through the retry policy.static DmxRetryof(io.github.resilience4j.retry.Retry retry) Wraps an existingRetryinstance.static DmxRetryCreates a newRetryfrom the given name and config, then wraps it.
-
Method Details
-
of
Wraps an existingRetryinstance.- Parameters:
retry- the Resilience4J retry policy to wrap- Returns:
- a new
DmxRetrybacked by the given retry policy
-
of
-
executeTry
Executes the supplier through the retry policy.- Type Parameters:
V- the value type- Parameters:
supplier- the operation to execute- Returns:
Success(value)if the call eventually succeeds,Failure(cause)if all attempts are exhausted
-
executeResult
Executes the supplier through the retry policy.- Type Parameters:
V- the value type- Parameters:
supplier- the operation to execute- Returns:
Ok(value)if the call eventually succeeds,Err(cause)if all attempts are exhausted
-