public interface Decorators
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.
| Modifier and Type | Interface and Description |
|---|---|
static class |
Decorators.DecorateCallable<T> |
static class |
Decorators.DecorateCheckedFunction<T,R> |
static class |
Decorators.DecorateCheckedRunnable |
static class |
Decorators.DecorateCheckedSupplier<T> |
static class |
Decorators.DecorateCompletionStage<T> |
static class |
Decorators.DecorateConsumer<T> |
static class |
Decorators.DecorateFunction<T,R> |
static class |
Decorators.DecorateRunnable |
static class |
Decorators.DecorateSupplier<T> |
| Modifier and Type | Method and Description |
|---|---|
static <T> Decorators.DecorateCallable<T> |
ofCallable(java.util.concurrent.Callable<T> callable) |
static <T,R> Decorators.DecorateCheckedFunction<T,R> |
ofCheckedFunction(io.vavr.CheckedFunction1<T,R> function) |
static Decorators.DecorateCheckedRunnable |
ofCheckedRunnable(io.vavr.CheckedRunnable supplier) |
static <T> Decorators.DecorateCheckedSupplier<T> |
ofCheckedSupplier(io.vavr.CheckedFunction0<T> supplier) |
static <T> Decorators.DecorateCompletionStage<T> |
ofCompletionStage(java.util.function.Supplier<java.util.concurrent.CompletionStage<T>> stageSupplier) |
static <T> Decorators.DecorateConsumer<T> |
ofConsumer(java.util.function.Consumer<T> consumer) |
static <T,R> Decorators.DecorateFunction<T,R> |
ofFunction(java.util.function.Function<T,R> function) |
static Decorators.DecorateRunnable |
ofRunnable(java.lang.Runnable runnable) |
static <T> Decorators.DecorateSupplier<T> |
ofSupplier(java.util.function.Supplier<T> supplier) |
static <T> Decorators.DecorateSupplier<T> ofSupplier(java.util.function.Supplier<T> supplier)
static <T,R> Decorators.DecorateFunction<T,R> ofFunction(java.util.function.Function<T,R> function)
static Decorators.DecorateRunnable ofRunnable(java.lang.Runnable runnable)
static <T> Decorators.DecorateCallable<T> ofCallable(java.util.concurrent.Callable<T> callable)
static <T> Decorators.DecorateCheckedSupplier<T> ofCheckedSupplier(io.vavr.CheckedFunction0<T> supplier)
static <T,R> Decorators.DecorateCheckedFunction<T,R> ofCheckedFunction(io.vavr.CheckedFunction1<T,R> function)
static Decorators.DecorateCheckedRunnable ofCheckedRunnable(io.vavr.CheckedRunnable supplier)
static <T> Decorators.DecorateCompletionStage<T> ofCompletionStage(java.util.function.Supplier<java.util.concurrent.CompletionStage<T>> stageSupplier)
static <T> Decorators.DecorateConsumer<T> ofConsumer(java.util.function.Consumer<T> consumer)