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 therecord
methods.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description void
complete()
Records and completes the execution successfully.java.time.Duration
getDelay()
Returns the time to delay before the next execution attempt.boolean
isComplete()
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 newExecution
that will use theouterPolicy
andinnerPolicies
to handle failures.void
record(R result, java.lang.Throwable exception)
Records an executionresult
orexception
which triggers failure handling, if needed, by the configured policies.void
recordException(java.lang.Throwable exception)
Records anexception
which triggers failure handling, if needed, by the configured policies.void
recordResult(R result)
Records an executionresult
which 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 newExecution
that will use theouterPolicy
andinnerPolicies
to handle failures. Policies are applied in reverse order, with the last policy being applied first.- Throws:
java.lang.NullPointerException
- ifouterPolicy
is 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. Returns0
if an execution has not yet occurred.
-
record
void record(R result, java.lang.Throwable exception)
Records an executionresult
orexception
which 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 executionresult
which 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 anexception
which 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
-
-