Package dev.failsafe
Interface Execution<R>
-
- Type Parameters:
R- result type
- All Superinterfaces:
ExecutionContext<R>
- All Known Subinterfaces:
SyncExecutionInternal<R>
- All Known Implementing Classes:
SyncExecutionImpl
public interface Execution<R> extends ExecutionContext<R>
Tracks synchronous executions and handles failures according to one or morepolicies. Execution results must be explicitly recorded via one of therecordmethods.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description voidcomplete()Records and completes the execution successfully.java.time.DurationgetDelay()Returns the time to delay before the next execution attempt.booleanisComplete()Returns whether the execution is complete or if it can be retried.static <R> Execution<R>of(Policy<R> outerPolicy, Policy<R>... policies)Creates a newExecutionthat will use theouterPolicyandinnerPoliciesto handle failures.voidrecord(R result, java.lang.Throwable exception)Records an executionresultorexceptionwhich triggers failure handling, if needed, by the configured policies.voidrecordException(java.lang.Throwable exception)Records anexceptionwhich triggers failure handling, if needed, by the configured policies.voidrecordResult(R result)Records an executionresultwhich triggers failure handling, if needed, by the configured policies.-
Methods inherited from interface dev.failsafe.ExecutionContext
getAttemptCount, getElapsedAttemptTime, getElapsedTime, getExecutionCount, getLastException, getLastResult, getLastResult, getStartTime, isCancelled, isFirstAttempt, isRetry, onCancel
-
-
-
-
Method Detail
-
of
@SafeVarargs static <R> Execution<R> of(Policy<R> outerPolicy, Policy<R>... policies)
Creates a newExecutionthat will use theouterPolicyandinnerPoliciesto handle failures. Policies are applied in reverse order, with the last policy being applied first.- Throws:
java.lang.NullPointerException- ifouterPolicyis null
-
complete
void complete()
Records and completes the execution successfully.- Throws:
java.lang.IllegalStateException- if the execution is already complete
-
isComplete
boolean isComplete()
Returns whether the execution is complete or if it can be retried. An execution is considered complete only when all configured policies consider the execution complete.
-
getDelay
java.time.Duration getDelay()
Returns the time to delay before the next execution attempt. Returns0if an execution has not yet occurred.
-
record
void record(R result, java.lang.Throwable exception)
Records an executionresultorexceptionwhich triggers failure handling, if needed, by the configured policies. If policy handling is not possible or completed, the execution is completed.- Throws:
java.lang.IllegalStateException- if the execution is already complete
-
recordResult
void recordResult(R result)
Records an executionresultwhich triggers failure handling, if needed, by the configured policies. If policy handling is not possible or completed, the execution is completed.- Throws:
java.lang.IllegalStateException- if the execution is already complete
-
recordException
void recordException(java.lang.Throwable exception)
Records anexceptionwhich triggers failure handling, if needed, by the configured policies. If policy handling is not possible or completed, the execution is completed.- Throws:
java.lang.IllegalStateException- if the execution is already complete
-
-