public interface ResilienceDecorationStrategy
Modifier and Type | Field and Description |
---|---|
static ExecutorService |
DEFAULT_EXECUTOR_SERVICE
The default executor service to manage queued Callables and Suppliers.
|
static ThreadFactory |
DEFAULT_THREAD_FACTORY
The default thread factory instance.
|
static String |
DEFAULT_THREAD_NAME_FORMAT
The default thread name format.
|
Modifier and Type | Method and Description |
---|---|
default void |
clearAllCacheEntries(ResilienceConfiguration configuration)
Clears the entire cache associated with the given
ResilienceConfiguration if any exists, independent of
the specified ResilienceIsolationMode and defined parameters. |
default void |
clearCache(ResilienceConfiguration configuration)
Clears the cache associated with the given
ResilienceConfiguration if any exists. |
default <T> Callable<T> |
decorateCallable(Callable<T> callable,
ResilienceConfiguration configuration)
Decorate an instance of a callable function.
|
<T> Callable<T> |
decorateCallable(Callable<T> callable,
ResilienceConfiguration configuration,
Function<? super Throwable,T> fallbackFunction)
Decorate an instance of a callable function.
|
default <T> Callable<T> |
decorateCallable(Callable<T> callable,
ResilienceConfiguration configuration,
Function<? super Throwable,T> fallbackFunction,
ExecutorService executor)
Decorate an instance of a callable function.
|
default <T> Supplier<T> |
decorateSupplier(Supplier<T> supplier,
ResilienceConfiguration configuration)
Decorate an instance of a supplier function.
|
<T> Supplier<T> |
decorateSupplier(Supplier<T> supplier,
ResilienceConfiguration configuration,
Function<? super Throwable,T> fallbackFunction)
Decorate an instance of a supplier function.
|
default <T> Supplier<T> |
decorateSupplier(Supplier<T> supplier,
ResilienceConfiguration configuration,
Function<? super Throwable,T> fallbackFunction,
ExecutorService executor)
Decorate an instance of a supplier function.
|
default <T> T |
executeCallable(Callable<T> callable,
ResilienceConfiguration configuration)
Decorate and execute an instance of a callable function.
|
default <T> T |
executeCallable(Callable<T> callable,
ResilienceConfiguration configuration,
Function<? super Throwable,T> fallbackFunction)
Decorate and execute an instance of a callable function.
|
default <T> T |
executeSupplier(Supplier<T> supplier,
ResilienceConfiguration configuration)
Decorate and execute an instance of a supplier function.
|
default <T> T |
executeSupplier(Supplier<T> supplier,
ResilienceConfiguration configuration,
Function<? super Throwable,T> fallbackFunction)
Decorate and execute an instance of a supplier function.
|
default void |
invalidateCache(ResilienceConfiguration configuration)
Deprecated.
Please use
clearAllCacheEntries(ResilienceConfiguration) to clear all cache entries for all
tenants and principals. You may also use clearCache(ResilienceConfiguration) to clear the
cache with respect to tenant/principal isolation. |
default <T> CompletableFuture<T> |
queueCallable(Callable<T> callable,
ResilienceConfiguration configuration,
Function<? super Throwable,T> fallbackFunction,
ExecutorService executor)
Decorate an instance of a callable function.
|
default <T> CompletableFuture<T> |
queueSupplier(Supplier<T> supplier,
ResilienceConfiguration configuration,
Function<? super Throwable,T> fallbackFunction,
ExecutorService executor)
Decorate an instance of a supplier function.
|
static final String DEFAULT_THREAD_NAME_FORMAT
static final ThreadFactory DEFAULT_THREAD_FACTORY
static final ExecutorService DEFAULT_EXECUTOR_SERVICE
@Deprecated default void invalidateCache(@Nonnull ResilienceConfiguration configuration)
clearAllCacheEntries(ResilienceConfiguration)
to clear all cache entries for all
tenants and principals. You may also use clearCache(ResilienceConfiguration)
to clear the
cache with respect to tenant/principal isolation.ResilienceConfiguration
if any exists. Be aware that the cache
will be cleared for all tenants and principals.configuration
- The ResilienceConfiguration
the cache is attached to.@Beta default void clearCache(@Nonnull ResilienceConfiguration configuration)
ResilienceConfiguration
if any exists. This method respects
tenant/principal isolation according to the ResilienceIsolationMode
as well as parameter isolation.clearAllCacheEntries(ResilienceConfiguration)
can be used instead.configuration
- The ResilienceConfiguration
the cache is attached to.default void clearAllCacheEntries(@Nonnull ResilienceConfiguration configuration)
ResilienceConfiguration
if any exists, independent of
the specified ResilienceIsolationMode
and defined parameters. Be aware that this operation affects all
tenants and principals.clearCache(ResilienceConfiguration)
to respect the tenant/principal and parameter isolation.configuration
- The ResilienceConfiguration
the cache is attached to.@Nonnull default <T> Supplier<T> decorateSupplier(@Nonnull Supplier<T> supplier, @Nonnull ResilienceConfiguration configuration)
T
- The return type of the call.supplier
- The supplier.configuration
- The configuration of the resilient call.@Nullable default <T> T executeSupplier(@Nonnull Supplier<T> supplier, @Nonnull ResilienceConfiguration configuration)
T
- The return type of the call.supplier
- The supplier.configuration
- The configuration of the resilient call.@Nonnull <T> Supplier<T> decorateSupplier(@Nonnull Supplier<T> supplier, @Nonnull ResilienceConfiguration configuration, @Nullable Function<? super Throwable,T> fallbackFunction)
T
- The return type of the call.supplier
- The supplier.configuration
- The configuration of the resilient call.fallbackFunction
- In case of failure, execute this function.@Nonnull default <T> Supplier<T> decorateSupplier(@Nonnull Supplier<T> supplier, @Nonnull ResilienceConfiguration configuration, @Nullable Function<? super Throwable,T> fallbackFunction, @Nullable ExecutorService executor)
T
- The return type of the call.supplier
- The supplier.configuration
- The configuration of the resilient call.fallbackFunction
- In case of failure, execute this function.executor
- (Optional) The thread executor to manage potentially asynchronous properties with, e.g. time limiter.@Nullable default <T> T executeSupplier(@Nonnull Supplier<T> supplier, @Nonnull ResilienceConfiguration configuration, @Nullable Function<? super Throwable,T> fallbackFunction)
T
- The return type of the call.supplier
- The supplier.configuration
- The configuration of the resilient call.fallbackFunction
- In case of failure, execute this function.@Nonnull default <T> Callable<T> decorateCallable(@Nonnull Callable<T> callable, @Nonnull ResilienceConfiguration configuration)
T
- The return type of the call.callable
- The callable.configuration
- The configuration of the resilient call.@Nullable default <T> T executeCallable(@Nonnull Callable<T> callable, @Nonnull ResilienceConfiguration configuration) throws Exception
T
- The return type of the call.callable
- The callable.configuration
- The configuration of the resilient call.Exception
- Exception that can be thrown by the callable.@Nonnull <T> Callable<T> decorateCallable(@Nonnull Callable<T> callable, @Nonnull ResilienceConfiguration configuration, @Nullable Function<? super Throwable,T> fallbackFunction)
T
- The return type of the call.callable
- The callable.configuration
- The configuration of the resilient call.fallbackFunction
- In case of failure, execute this function.@Nonnull default <T> Callable<T> decorateCallable(@Nonnull Callable<T> callable, @Nonnull ResilienceConfiguration configuration, @Nullable Function<? super Throwable,T> fallbackFunction, @Nullable ExecutorService executor)
T
- The return type of the call.callable
- The callable.configuration
- The configuration of the resilient call.fallbackFunction
- In case of failure, execute this function.executor
- (Optional) The thread executor to manage potentially asynchronous properties with, e.g. time limiter.@Nullable default <T> T executeCallable(@Nonnull Callable<T> callable, @Nonnull ResilienceConfiguration configuration, @Nullable Function<? super Throwable,T> fallbackFunction)
fallbackFunction
handles any exceptions thrown by callable
, and fallbackFunction
does not throw any exceptions
itself. If fallbackFunction
throws any exception, then it will be wrapped in a
ResilienceRuntimeException
.T
- The return type of the call.callable
- The callable.configuration
- The configuration of the resilient call.fallbackFunction
- (Optional) In case of failure, execute this function.@Nonnull default <T> CompletableFuture<T> queueCallable(@Nonnull Callable<T> callable, @Nonnull ResilienceConfiguration configuration, @Nullable Function<? super Throwable,T> fallbackFunction, @Nullable ExecutorService executor)
T
- The return type of the call.callable
- The callable.configuration
- The configuration of the resilient call.fallbackFunction
- (Optional) In case of failure, execute this function.executor
- (Optional) The thread executor to schedule the asynchronous operation with.@Nonnull default <T> CompletableFuture<T> queueSupplier(@Nonnull Supplier<T> supplier, @Nonnull ResilienceConfiguration configuration, @Nullable Function<? super Throwable,T> fallbackFunction, @Nullable ExecutorService executor)
T
- The return type of the call.supplier
- The supplier.configuration
- The configuration of the resilient call.fallbackFunction
- (Optional) In case of failure, execute this function.executor
- (Optional) The thread executor to schedule the asynchronous operation with.Copyright © 2021 SAP SE. All rights reserved.