Interface Decorators
public interface Decorators
A Decorator builder which can be used to apply multiple decorators to a Supplier, Callable
Function, Runnable, CompletionStage or Consumer.
Decorators are applied in the order of the builder chain. For example, consider:
Supplier<String> supplier = Decorators
.ofSupplier(() -> service.method())
.withCircuitBreaker(CircuitBreaker.ofDefaults("id"))
.withRetry(Retry.ofDefaults("id"))
.withFallback(CallNotPermittedException.class, e -> service.fallbackMethod())
.decorate();
This results in the following composition when executing the supplier: Fallback(Retry(CircuitBreaker(Supplier)))This means the Supplier is called first, then its result is handled by the CircuitBreaker, then Retry and then Fallback. Each Decorator makes its own determination whether an exception represents a failure.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic class -
Method Summary
Static MethodsModifier and TypeMethodDescriptionstatic <T> Decorators.DecorateCallable<T>ofCallable(Callable<T> callable) static <T,R> Decorators.DecorateCheckedFunction<T, R> ofCheckedFunction(io.github.resilience4j.core.functions.CheckedFunction<T, R> function) ofCheckedRunnable(io.github.resilience4j.core.functions.CheckedRunnable supplier) static <T> Decorators.DecorateCheckedSupplier<T>ofCheckedSupplier(io.github.resilience4j.core.functions.CheckedSupplier<T> supplier) static <T> Decorators.DecorateCompletionStage<T>ofCompletionStage(Supplier<CompletionStage<T>> stageSupplier) static <T> Decorators.DecorateConsumer<T>ofConsumer(Consumer<T> consumer) static <T,R> Decorators.DecorateFunction<T, R> ofFunction(Function<T, R> function) static Decorators.DecorateRunnableofRunnable(Runnable runnable) static <T> Decorators.DecorateSupplier<T>ofSupplier(Supplier<T> supplier)
-
Method Details
-
ofSupplier
-
ofFunction
-
ofRunnable
-
ofCallable
-
ofCheckedSupplier
static <T> Decorators.DecorateCheckedSupplier<T> ofCheckedSupplier(io.github.resilience4j.core.functions.CheckedSupplier<T> supplier) -
ofCheckedFunction
static <T,R> Decorators.DecorateCheckedFunction<T,R> ofCheckedFunction(io.github.resilience4j.core.functions.CheckedFunction<T, R> function) -
ofCheckedRunnable
static Decorators.DecorateCheckedRunnable ofCheckedRunnable(io.github.resilience4j.core.functions.CheckedRunnable supplier) -
ofCompletionStage
static <T> Decorators.DecorateCompletionStage<T> ofCompletionStage(Supplier<CompletionStage<T>> stageSupplier) -
ofConsumer
-