Package dev.failsafe.internal
Class BulkheadExecutor<R>
- java.lang.Object
-
- dev.failsafe.spi.PolicyExecutor<R>
-
- dev.failsafe.internal.BulkheadExecutor<R>
-
- Type Parameters:
R
- result type
public class BulkheadExecutor<R> extends PolicyExecutor<R>
A PolicyExecutor that handles failures according to aBulkhead
.
-
-
Field Summary
Fields Modifier and Type Field Description private BulkheadImpl<R>
bulkhead
private java.time.Duration
maxWaitTime
-
Constructor Summary
Constructors Constructor Description BulkheadExecutor(BulkheadImpl<R> bulkhead, int policyIndex)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ExecutionResult<R>
onFailure(ExecutionContext<R> context, ExecutionResult<R> result)
Performs post-execution handling for aresult
that is considered a failure according toPolicyExecutor.isFailure(ExecutionResult)
, possibly creating a new result, else returning the originalresult
.void
onSuccess(ExecutionResult<R> result)
Performs post-execution handling for aresult
that is considered a success according toPolicyExecutor.isFailure(ExecutionResult)
.protected ExecutionResult<R>
preExecute()
Called before execution to return an alternative result or exception such as if execution is not allowed or needed.protected java.util.concurrent.CompletableFuture<ExecutionResult<R>>
preExecuteAsync(Scheduler scheduler, FailsafeFuture<R> future)
Called before an async execution to return an alternative result or exception such as if execution is not allowed or needed.-
Methods inherited from class dev.failsafe.spi.PolicyExecutor
apply, applyAsync, getPolicyIndex, isFailure, onFailureAsync, postExecute, postExecuteAsync
-
-
-
-
Field Detail
-
bulkhead
private final BulkheadImpl<R> bulkhead
-
maxWaitTime
private final java.time.Duration maxWaitTime
-
-
Constructor Detail
-
BulkheadExecutor
public BulkheadExecutor(BulkheadImpl<R> bulkhead, int policyIndex)
-
-
Method Detail
-
preExecute
protected ExecutionResult<R> preExecute()
Description copied from class:PolicyExecutor
Called before execution to return an alternative result or exception such as if execution is not allowed or needed.- Overrides:
preExecute
in classPolicyExecutor<R>
-
preExecuteAsync
protected java.util.concurrent.CompletableFuture<ExecutionResult<R>> preExecuteAsync(Scheduler scheduler, FailsafeFuture<R> future)
Description copied from class:PolicyExecutor
Called before an async execution to return an alternative result or exception such as if execution is not allowed or needed. Returnsnull
if pre execution is not performed. If the resulting future is completed with anon-result
, then execution and post-execution should still be performed. If the resulting future is completed withnull
, then the execution is assumed to have been cancelled.- Overrides:
preExecuteAsync
in classPolicyExecutor<R>
-
onSuccess
public void onSuccess(ExecutionResult<R> result)
Description copied from class:PolicyExecutor
Performs post-execution handling for aresult
that is considered a success according toPolicyExecutor.isFailure(ExecutionResult)
.- Overrides:
onSuccess
in classPolicyExecutor<R>
-
onFailure
protected ExecutionResult<R> onFailure(ExecutionContext<R> context, ExecutionResult<R> result)
Description copied from class:PolicyExecutor
Performs post-execution handling for aresult
that is considered a failure according toPolicyExecutor.isFailure(ExecutionResult)
, possibly creating a new result, else returning the originalresult
.- Overrides:
onFailure
in classPolicyExecutor<R>
-
-