Package | Description |
---|---|
dev.failsafe.spi |
The Failsafe Service Provider Interface (SPI).
|
Modifier and Type | Method and Description |
---|---|
static <R> ExecutionResult<R> |
ExecutionResult.exception(Throwable exception)
Returns an ExecutionResult with the
exception set, complete true and success false. |
ExecutionResult<R> |
ExecutionInternal.getResult()
Returns the recorded result for an execution attempt.
|
static <R> ExecutionResult<R> |
ExecutionResult.none()
Returns an execution that was completed with a non-result.
|
protected ExecutionResult<R> |
PolicyExecutor.onFailure(ExecutionContext<R> context,
ExecutionResult<R> result)
Performs post-execution handling for a
result that is considered a failure according to PolicyExecutor.isFailure(ExecutionResult) , possibly creating a new result, else returning the original result . |
ExecutionResult<R> |
PolicyExecutor.postExecute(ExecutionInternal<R> execution,
ExecutionResult<R> result)
Performs synchronous post-execution handling for a
result . |
protected ExecutionResult<R> |
PolicyExecutor.preExecute()
Called before execution to return an alternative result or exception such as if execution is not allowed or needed.
|
static <R> ExecutionResult<R> |
ExecutionResult.success(R result)
Returns an ExecutionResult with the
result set, complete true and success true. |
ExecutionResult<R> |
ExecutionResult.with(long delayNanos,
boolean complete,
boolean success)
Returns a copy of the ExecutionResult with the
delayNanos , complete and success values. |
ExecutionResult<R> |
ExecutionResult.withDelay(long delayNanos)
Returns a copy of the ExecutionResult with the
delayNanos value. |
ExecutionResult<R> |
ExecutionResult.withException()
Returns a copy of the ExecutionResult with success value of {code false}.
|
ExecutionResult<R> |
ExecutionResult.withNonResult()
Returns a copy of the ExecutionResult with a non-result, and complete and success set to true.
|
ExecutionResult<R> |
ExecutionResult.withNotComplete()
Returns a copy of the ExecutionResult with
complete set to false, else this if nothing has changed. |
ExecutionResult<R> |
ExecutionResult.withResult(R result)
Returns a copy of the ExecutionResult with the
result value, and complete and success set to true. |
ExecutionResult<R> |
ExecutionResult.withSuccess()
Returns a copy of the ExecutionResult with the
complete and success values of true . |
Modifier and Type | Method and Description |
---|---|
Function<SyncExecutionInternal<R>,ExecutionResult<R>> |
PolicyExecutor.apply(Function<SyncExecutionInternal<R>,ExecutionResult<R>> innerFn,
Scheduler scheduler)
Performs an execution by calling pre-execute else calling the supplier and doing a post-execute.
|
Function<AsyncExecutionInternal<R>,CompletableFuture<ExecutionResult<R>>> |
PolicyExecutor.applyAsync(Function<AsyncExecutionInternal<R>,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.
|
static <R> CompletableFuture<ExecutionResult<R>> |
ExecutionResult.nullFuture()
Returns a CompletableFuture that is completed with
null . |
protected CompletableFuture<ExecutionResult<R>> |
PolicyExecutor.onFailureAsync(ExecutionContext<R> context,
ExecutionResult<R> result,
Scheduler scheduler,
FailsafeFuture<R> future)
Performs potentially asynchrononus post-execution handling for a failed
result , possibly creating a new
result, else returning the original result . |
protected CompletableFuture<ExecutionResult<R>> |
PolicyExecutor.postExecuteAsync(AsyncExecutionInternal<R> execution,
ExecutionResult<R> result,
Scheduler scheduler,
FailsafeFuture<R> future)
Performs potentially asynchronous post-execution handling for a
result . |
protected CompletableFuture<ExecutionResult<R>> |
PolicyExecutor.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.
|
Modifier and Type | Method and Description |
---|---|
void |
FailsafeFuture.cancelDependencies(PolicyExecutor<R> cancellingPolicyExecutor,
boolean mayInterrupt,
ExecutionResult<R> cancelResult)
Applies any
cancel functions with the cancelResult for
PolicyExecutors whose policyIndex is < the policyIndex of the cancellingPolicyExecutor . |
boolean |
FailsafeFuture.completeResult(ExecutionResult<R> result)
Completes the execution with the
result and calls the completion handler. |
protected boolean |
PolicyExecutor.isFailure(ExecutionResult<R> result)
Returns whether the
result is a success according to the policy. |
protected ExecutionResult<R> |
PolicyExecutor.onFailure(ExecutionContext<R> context,
ExecutionResult<R> result)
Performs post-execution handling for a
result that is considered a failure according to PolicyExecutor.isFailure(ExecutionResult) , possibly creating a new result, else returning the original result . |
protected CompletableFuture<ExecutionResult<R>> |
PolicyExecutor.onFailureAsync(ExecutionContext<R> context,
ExecutionResult<R> result,
Scheduler scheduler,
FailsafeFuture<R> future)
Performs potentially asynchrononus post-execution handling for a failed
result , possibly creating a new
result, else returning the original result . |
protected void |
PolicyExecutor.onSuccess(ExecutionResult<R> result)
Performs post-execution handling for a
result that is considered a success according to PolicyExecutor.isFailure(ExecutionResult) . |
ExecutionResult<R> |
PolicyExecutor.postExecute(ExecutionInternal<R> execution,
ExecutionResult<R> result)
Performs synchronous post-execution handling for a
result . |
protected CompletableFuture<ExecutionResult<R>> |
PolicyExecutor.postExecuteAsync(AsyncExecutionInternal<R> execution,
ExecutionResult<R> result,
Scheduler scheduler,
FailsafeFuture<R> future)
Performs potentially asynchronous post-execution handling for a
result . |
void |
ExecutionInternal.record(ExecutionResult<R> result)
Records the
result if the execution has been pre-executed and a result has not
already been recorded. |
Modifier and Type | Method and Description |
---|---|
Function<SyncExecutionInternal<R>,ExecutionResult<R>> |
PolicyExecutor.apply(Function<SyncExecutionInternal<R>,ExecutionResult<R>> innerFn,
Scheduler scheduler)
Performs an execution by calling pre-execute else calling the supplier and doing a post-execute.
|
Function<AsyncExecutionInternal<R>,CompletableFuture<ExecutionResult<R>>> |
PolicyExecutor.applyAsync(Function<AsyncExecutionInternal<R>,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.
|
void |
FailsafeFuture.setCancelFn(int policyIndex,
BiConsumer<Boolean,ExecutionResult<R>> cancelFn)
Sets a
cancelFn to be called when a PolicyExecutor cancels dependencies with a policyIndex > the given policyIndex , or when this future is
cancelled . |
void |
FailsafeFuture.setCancelFn(PolicyExecutor<R> policyExecutor,
BiConsumer<Boolean,ExecutionResult<R>> cancelFn)
Sets a
cancelFn to be called when a PolicyExecutor cancels dependencies with a policyIndex > the policyIndex of the given policyExecutor , or
when this future is cancelled . |
Constructor and Description |
---|
FailsafeFuture(BiConsumer<ExecutionResult<R>,ExecutionContext<R>> completionHandler) |
Copyright © 2022. All rights reserved.