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 TypeMethodDescriptionvoidcomplete()Records and completes the execution successfully.getDelay()Returns the time to delay before the next execution attempt.booleanReturns whether the execution is complete or if it can be retried.static <R> Execution<R> Creates a newExecutionthat will use theouterPolicyandinnerPoliciesto handle failures.voidRecords an executionresultorexceptionwhich triggers failure handling, if needed, by the configured policies.voidrecordException(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 Details
-
of
Creates a newExecutionthat will use theouterPolicyandinnerPoliciesto handle failures. Policies are applied in reverse order, with the last policy being applied first.- Throws:
NullPointerException- ifouterPolicyis 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. Returns0if an execution has not yet occurred. -
record
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:
IllegalStateException- if the execution is already complete
-
recordResult
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:
IllegalStateException- if the execution is already complete
-
recordException
Records anexceptionwhich 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
-