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
Tracks synchronous executions and handles failures according to one or more
policies
. Execution
results must be explicitly recorded via one of the record
methods.-
Method Summary
Modifier and TypeMethodDescriptionvoid
complete()
Records and completes the execution successfully.getDelay()
Returns the time to delay before the next execution attempt.boolean
Returns whether the execution is complete or if it can be retried.static <R> Execution
<R> Creates a newExecution
that will use theouterPolicy
andinnerPolicies
to handle failures.void
Records an executionresult
orexception
which triggers failure handling, if needed, by the configured policies.void
recordException
(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 Details
-
of
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:
NullPointerException
- ifouterPolicy
is null
-
complete
void complete()Records and completes the execution successfully.- Throws:
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
Duration getDelay()Returns the time to delay before the next execution attempt. Returns0
if an execution has not yet occurred. -
record
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:
IllegalStateException
- if the execution is already complete
-
recordResult
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:
IllegalStateException
- if the execution is already complete
-
recordException
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:
IllegalStateException
- if the execution is already complete
-