Package dev.failsafe.internal
Class FallbackExecutor<R>
- java.lang.Object
-
- dev.failsafe.spi.PolicyExecutor<R>
-
- dev.failsafe.internal.FallbackExecutor<R>
-
- Type Parameters:
R
- result type
public class FallbackExecutor<R> extends PolicyExecutor<R>
A PolicyExecutor that handles failures according to aFallback
.
-
-
Field Summary
Fields Modifier and Type Field Description private FallbackConfig<R>
config
private EventHandler<R>
failedAttemptHandler
private FallbackImpl<R>
fallback
-
Constructor Summary
Constructors Constructor Description FallbackExecutor(FallbackImpl<R> fallback, int policyIndex)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.function.Function<SyncExecutionInternal<R>,ExecutionResult<R>>
apply(java.util.function.Function<SyncExecutionInternal<R>,ExecutionResult<R>> innerFn, Scheduler scheduler)
Performs an execution by calling pre-execute else calling the supplier, applying a fallback if it fails, and calling post-execute.java.util.function.Function<AsyncExecutionInternal<R>,java.util.concurrent.CompletableFuture<ExecutionResult<R>>>
applyAsync(java.util.function.Function<AsyncExecutionInternal<R>,java.util.concurrent.CompletableFuture<ExecutionResult<R>>> innerFn, Scheduler scheduler, FailsafeFuture<R> future)
Performs an async execution by calling pre-execute else calling the supplier and doing a post-execute.-
Methods inherited from class dev.failsafe.spi.PolicyExecutor
getPolicyIndex, isFailure, onFailure, onFailureAsync, onSuccess, postExecute, postExecuteAsync, preExecute, preExecuteAsync
-
-
-
-
Field Detail
-
fallback
private final FallbackImpl<R> fallback
-
config
private final FallbackConfig<R> config
-
failedAttemptHandler
private final EventHandler<R> failedAttemptHandler
-
-
Constructor Detail
-
FallbackExecutor
public FallbackExecutor(FallbackImpl<R> fallback, int policyIndex)
-
-
Method Detail
-
apply
public java.util.function.Function<SyncExecutionInternal<R>,ExecutionResult<R>> apply(java.util.function.Function<SyncExecutionInternal<R>,ExecutionResult<R>> innerFn, Scheduler scheduler)
Performs an execution by calling pre-execute else calling the supplier, applying a fallback if it fails, and calling post-execute.- Overrides:
apply
in classPolicyExecutor<R>
-
applyAsync
public java.util.function.Function<AsyncExecutionInternal<R>,java.util.concurrent.CompletableFuture<ExecutionResult<R>>> applyAsync(java.util.function.Function<AsyncExecutionInternal<R>,java.util.concurrent.CompletableFuture<ExecutionResult<R>>> innerFn, Scheduler scheduler, FailsafeFuture<R> future)
Performs an async execution by calling pre-execute else calling the supplier and doing a post-execute.- Overrides:
applyAsync
in classPolicyExecutor<R>
-
-