R
- result typepublic interface ExecutionContext<R>
Modifier and Type | Method and Description |
---|---|
int |
getAttemptCount()
Gets the number of execution attempts so far, including attempts that are blocked before being executed, such as
when a
CircuitBreaker is open. |
Duration |
getElapsedAttemptTime()
Returns the elapsed time since the last execution attempt began.
|
Duration |
getElapsedTime()
Returns the elapsed time since initial execution began.
|
int |
getExecutionCount()
Gets the number of completed executions so far.
|
<T extends Throwable> |
getLastException()
Returns the last exception that was recorded else
null . |
R |
getLastResult()
Returns the last result that was recorded else
null . |
R |
getLastResult(R defaultValue)
Returns the last result that was recorded else the
defaultValue . |
Instant |
getStartTime()
Returns the time that the initial execution started.
|
boolean |
isCancelled()
Returns whether the execution has been cancelled.
|
boolean |
isFirstAttempt()
Returns
true when an execution result has not yet been recorded, meaning this is the first execution
attempt. |
boolean |
isRetry()
Returns
true when an execution result has already been recorded, meaning the execution is being retried. |
void |
onCancel(CheckedRunnable cancelCallback)
Sets the
cancelCallback to be called if the execution is cancelled, such as by the resulting Call
or CompletableFuture , or a Timeout . |
void onCancel(CheckedRunnable cancelCallback)
cancelCallback
to be called if the execution is cancelled, such as by the resulting Call
or CompletableFuture
, or a Timeout
. Any exception thrown by the cancelCallback
is ignored.Duration getElapsedTime()
Duration getElapsedAttemptTime()
int getAttemptCount()
CircuitBreaker
is open. Will return 0
when the first attempt is in progress or has yet to
begin.int getExecutionCount()
CircuitBreaker
is open, are not counted. Will return 0
when the first attempt is in progress or has yet to begin.<T extends Throwable> T getLastException()
null
.R getLastResult()
null
.R getLastResult(R defaultValue)
defaultValue
.Instant getStartTime()
boolean isCancelled()
boolean isFirstAttempt()
true
when an execution result has not yet been recorded, meaning this is the first execution
attempt.boolean isRetry()
true
when an execution result has already been recorded, meaning the execution is being retried.Copyright © 2022. All rights reserved.