Package io.github.resilience4j.retry
Interface Retry
- All Known Implementing Classes:
RetryImpl
public interface Retry
A Retry instance is thread-safe can be used to decorate multiple requests. A Retry.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
static class
static interface
the retry context which will be used during the retry iteration to decide what can be done on error , result, on runtime errorstatic interface
An EventPublisher which subscribes to the reactive stream of RetryEvents and can be used to register event consumers.static interface
-
Method Summary
Modifier and TypeMethodDescription<T> Retry.AsyncContext<T>
Creates a async retry Context.<T> Retry.Context<T>
context()
Creates a retry Context.static <T> Callable<T>
decorateCallable
(Retry retry, Callable<T> supplier) Creates a retryable callable.default <T> Callable<T>
decorateCallable
(Callable<T> supplier) Creates a retryable callable using current instance as context.default <T> io.github.resilience4j.core.functions.CheckedConsumer<T>
decorateCheckedConsumer
(io.github.resilience4j.core.functions.CheckedConsumer<T> consumer) Creates a retryable consumer using current instance as context.static <T> io.github.resilience4j.core.functions.CheckedConsumer<T>
decorateCheckedConsumer
(Retry retry, io.github.resilience4j.core.functions.CheckedConsumer<T> consumer) Creates a retryable consumer.default <T,
R> io.github.resilience4j.core.functions.CheckedFunction<T, R> decorateCheckedFunction
(io.github.resilience4j.core.functions.CheckedFunction<T, R> function) Creates a retryable function using current instance as context.static <T,
R> io.github.resilience4j.core.functions.CheckedFunction<T, R> decorateCheckedFunction
(Retry retry, io.github.resilience4j.core.functions.CheckedFunction<T, R> function) Creates a retryable function.default io.github.resilience4j.core.functions.CheckedRunnable
decorateCheckedRunnable
(io.github.resilience4j.core.functions.CheckedRunnable runnable) Creates a retryable runnable using current instance as context.static io.github.resilience4j.core.functions.CheckedRunnable
decorateCheckedRunnable
(Retry retry, io.github.resilience4j.core.functions.CheckedRunnable runnable) Creates a retryable runnable.default <T> io.github.resilience4j.core.functions.CheckedSupplier<T>
decorateCheckedSupplier
(io.github.resilience4j.core.functions.CheckedSupplier<T> supplier) Creates a retryable supplier using current instance as context.static <T> io.github.resilience4j.core.functions.CheckedSupplier<T>
decorateCheckedSupplier
(Retry retry, io.github.resilience4j.core.functions.CheckedSupplier<T> supplier) Creates a retryable supplier.static <T> Supplier<CompletionStage<T>>
decorateCompletionStage
(Retry retry, ScheduledExecutorService scheduler, Supplier<CompletionStage<T>> supplier) Decorates CompletionStageSupplier with Retrydefault <T> Supplier<CompletionStage<T>>
decorateCompletionStage
(ScheduledExecutorService scheduler, Supplier<CompletionStage<T>> supplier) Decorates CompletionStageSupplier using current instance as context.static <T> Consumer<T>
decorateConsumer
(Retry retry, Consumer<T> consumer) Creates a retryable consumer.default <T> Consumer<T>
decorateConsumer
(Consumer<T> consumer) Creates a retryable consumer using current instance as context.static <T,
R> Function<T, R> decorateFunction
(Retry retry, Function<T, R> function) Creates a retryable function.static Runnable
decorateRunnable
(Retry retry, Runnable runnable) Creates a retryable runnable.default Runnable
decorateRunnable
(Runnable runnable) Creates a retryable runnable using current instance as context.static <T> Supplier<T>
decorateSupplier
(Retry retry, Supplier<T> supplier) Creates a retryable supplier.default <T> Supplier<T>
decorateSupplier
(Supplier<T> supplier) Creates a retryable supplier using current instance as context.default <T> T
executeCallable
(Callable<T> callable) Decorates and executes the decorated Callable.default <T> T
executeCheckedSupplier
(io.github.resilience4j.core.functions.CheckedSupplier<T> checkedSupplier) Decorates and executes the decorated Supplier.default <T> CompletionStage<T>
executeCompletionStage
(ScheduledExecutorService scheduler, Supplier<CompletionStage<T>> supplier) Decorates and executes the decorated CompletionStage.default void
executeRunnable
(Runnable runnable) Decorates and executes the decorated Runnable.default <T> T
executeSupplier
(Supplier<T> supplier) Decorates and executes the decorated Supplier.Returns an EventPublisher can be used to register event consumers.Get the Metrics of this Retry instance.getName()
Returns the ID of this Retry.Returns the RetryConfig of this Retry.getTags()
Returns an unmodifiable map with tags assigned to this Retry.static Retry
of
(String name, RetryConfig retryConfig) Creates a Retry with a custom Retry configuration.static Retry
Creates a Retry with a custom Retry configuration.static Retry
of
(String name, Supplier<RetryConfig> retryConfigSupplier) Creates a Retry with a custom Retry configuration.static Retry
Creates a Retry with a custom Retry configuration.static Retry
ofDefaults
(String name) Creates a Retry with default configuration.
-
Method Details
-
of
Creates a Retry with a custom Retry configuration.- Parameters:
name
- the ID of the RetryretryConfig
- a custom Retry configuration- Returns:
- a Retry with a custom Retry configuration.
-
of
Creates a Retry with a custom Retry configuration.- Parameters:
name
- the ID of the RetryretryConfig
- a custom Retry configurationtags
- tags to assign to the Retry- Returns:
- a Retry with a custom Retry configuration.
-
of
Creates a Retry with a custom Retry configuration.- Parameters:
name
- the ID of the RetryretryConfigSupplier
- a supplier of a custom Retry configuration- Returns:
- a Retry with a custom Retry configuration.
-
of
Creates a Retry with a custom Retry configuration.- Parameters:
name
- the ID of the RetryretryConfigSupplier
- a supplier of a custom Retry configurationtags
- tags to assign to the Retry- Returns:
- a Retry with a custom Retry configuration.
-
ofDefaults
Creates a Retry with default configuration.- Parameters:
name
- the ID of the Retry- Returns:
- a Retry with default configuration
-
decorateCompletionStage
static <T> Supplier<CompletionStage<T>> decorateCompletionStage(Retry retry, ScheduledExecutorService scheduler, Supplier<CompletionStage<T>> supplier) Decorates CompletionStageSupplier with Retry- Type Parameters:
T
- type of completion stage result- Parameters:
retry
- the retry contextscheduler
- execution service to use to schedule retriessupplier
- completion stage supplier- Returns:
- decorated supplier
-
decorateCompletionStage
default <T> Supplier<CompletionStage<T>> decorateCompletionStage(ScheduledExecutorService scheduler, Supplier<CompletionStage<T>> supplier) Decorates CompletionStageSupplier using current instance as context.- Type Parameters:
T
- type of completion stage result- Parameters:
scheduler
- execution service to use to schedule retriessupplier
- completion stage supplier- Returns:
- decorated supplier
-
decorateCheckedSupplier
static <T> io.github.resilience4j.core.functions.CheckedSupplier<T> decorateCheckedSupplier(Retry retry, io.github.resilience4j.core.functions.CheckedSupplier<T> supplier) Creates a retryable supplier.- Type Parameters:
T
- the type of results supplied by this supplier- Parameters:
retry
- the retry contextsupplier
- the original function- Returns:
- a retryable function
-
decorateCheckedSupplier
default <T> io.github.resilience4j.core.functions.CheckedSupplier<T> decorateCheckedSupplier(io.github.resilience4j.core.functions.CheckedSupplier<T> supplier) Creates a retryable supplier using current instance as context.- Type Parameters:
T
- the type of results supplied by this supplier- Parameters:
supplier
- the original function- Returns:
- a retryable function
-
decorateCheckedRunnable
static io.github.resilience4j.core.functions.CheckedRunnable decorateCheckedRunnable(Retry retry, io.github.resilience4j.core.functions.CheckedRunnable runnable) Creates a retryable runnable.- Parameters:
retry
- the retry contextrunnable
- the original runnable- Returns:
- a retryable runnable
-
decorateCheckedRunnable
default io.github.resilience4j.core.functions.CheckedRunnable decorateCheckedRunnable(io.github.resilience4j.core.functions.CheckedRunnable runnable) Creates a retryable runnable using current instance as context.- Parameters:
runnable
- the original runnable- Returns:
- a retryable runnable
-
decorateCheckedFunction
static <T,R> io.github.resilience4j.core.functions.CheckedFunction<T,R> decorateCheckedFunction(Retry retry, io.github.resilience4j.core.functions.CheckedFunction<T, R> function) Creates a retryable function.- Type Parameters:
T
- the type of the input to the functionR
- the result type of the function- Parameters:
retry
- the retry contextfunction
- the original function- Returns:
- a retryable function
-
decorateCheckedFunction
default <T,R> io.github.resilience4j.core.functions.CheckedFunction<T,R> decorateCheckedFunction(io.github.resilience4j.core.functions.CheckedFunction<T, R> function) Creates a retryable function using current instance as context.- Type Parameters:
T
- the type of the input to the functionR
- the result type of the function- Parameters:
function
- the original function- Returns:
- a retryable function
-
decorateCheckedConsumer
static <T> io.github.resilience4j.core.functions.CheckedConsumer<T> decorateCheckedConsumer(Retry retry, io.github.resilience4j.core.functions.CheckedConsumer<T> consumer) Creates a retryable consumer.- Type Parameters:
T
- the type of the input to the consumer- Parameters:
retry
- the retry contextconsumer
- the original consumer- Returns:
- a retryable consumer
-
decorateCheckedConsumer
default <T> io.github.resilience4j.core.functions.CheckedConsumer<T> decorateCheckedConsumer(io.github.resilience4j.core.functions.CheckedConsumer<T> consumer) Creates a retryable consumer using current instance as context.- Type Parameters:
T
- the type of the input to the consumer- Parameters:
consumer
- the original consumer- Returns:
- a retryable consumer
-
decorateSupplier
Creates a retryable supplier.- Type Parameters:
T
- the type of results supplied by this supplier- Parameters:
retry
- the retry contextsupplier
- the original function- Returns:
- a retryable function
-
decorateSupplier
Creates a retryable supplier using current instance as context.- Type Parameters:
T
- the type of results supplied by this supplier- Parameters:
supplier
- the original function- Returns:
- a retryable function
-
decorateCallable
Creates a retryable callable.- Type Parameters:
T
- the type of results supplied by this supplier- Parameters:
retry
- the retry contextsupplier
- the original function- Returns:
- a retryable function
-
decorateCallable
Creates a retryable callable using current instance as context.- Type Parameters:
T
- the type of results supplied by this supplier- Parameters:
supplier
- the original function- Returns:
- a retryable function
-
decorateRunnable
Creates a retryable runnable.- Parameters:
retry
- the retry contextrunnable
- the original runnable- Returns:
- a retryable runnable
-
decorateRunnable
Creates a retryable runnable using current instance as context.- Parameters:
runnable
- the original runnable- Returns:
- a retryable runnable
-
decorateFunction
Creates a retryable function.- Type Parameters:
T
- the type of the input to the functionR
- the result type of the function- Parameters:
retry
- the retry contextfunction
- the original function- Returns:
- a retryable function
-
decorateConsumer
Creates a retryable consumer.- Type Parameters:
T
- the type of the input to the consumer- Parameters:
retry
- the retry contextconsumer
- the original consumer- Returns:
- a retryable consumer
-
decorateConsumer
Creates a retryable consumer using current instance as context.- Parameters:
consumer
- the original consumer- Returns:
- a retryable consumer
-
getName
String getName()Returns the ID of this Retry.- Returns:
- the ID of this Retry
-
context
Creates a retry Context.- Returns:
- the retry Context
-
asyncContext
Creates a async retry Context.- Returns:
- the async retry Context
-
getRetryConfig
RetryConfig getRetryConfig()Returns the RetryConfig of this Retry.- Returns:
- the RetryConfig of this Retry
-
getTags
Returns an unmodifiable map with tags assigned to this Retry.- Returns:
- the tags assigned to this Retry in an unmodifiable map
-
getEventPublisher
Retry.EventPublisher getEventPublisher()Returns an EventPublisher can be used to register event consumers.- Returns:
- an EventPublisher
-
executeCheckedSupplier
default <T> T executeCheckedSupplier(io.github.resilience4j.core.functions.CheckedSupplier<T> checkedSupplier) throws Throwable Decorates and executes the decorated Supplier.- Type Parameters:
T
- the type of results supplied by this supplier- Parameters:
checkedSupplier
- the original Supplier- Returns:
- the result of the decorated Supplier.
- Throws:
Throwable
- if something goes wrong applying this function to the given arguments
-
executeSupplier
Decorates and executes the decorated Supplier.- Type Parameters:
T
- the type of results supplied by this supplier- Parameters:
supplier
- the original Supplier- Returns:
- the result of the decorated Supplier.
-
executeCallable
Decorates and executes the decorated Callable.- Type Parameters:
T
- the result type of callable- Parameters:
callable
- the original Callable- Returns:
- the result of the decorated Callable.
- Throws:
Exception
- if unable to compute a result
-
executeRunnable
Decorates and executes the decorated Runnable.- Parameters:
runnable
- the original Runnable
-
executeCompletionStage
default <T> CompletionStage<T> executeCompletionStage(ScheduledExecutorService scheduler, Supplier<CompletionStage<T>> supplier) Decorates and executes the decorated CompletionStage.- Type Parameters:
T
- the type of results supplied by this supplier- Parameters:
scheduler
- execution service to use to schedule retriessupplier
- the original CompletionStage- Returns:
- the decorated CompletionStage.
-
getMetrics
Retry.Metrics getMetrics()Get the Metrics of this Retry instance.- Returns:
- the Metrics of this Retry instance
-