Interface RequestExecutionLifetime
public interface RequestExecutionLifetime
Controls the lifetime of a
RequestExecutionEngine run and reports when it finishes.
Obtained from RequestExecution.lifetime().
A run can be paused and resumed, or cancelled outright. Completion is observed either by blocking on awaitCompletion()
or by registering an onComplete callback - the API
deliberately does not expose a CompletableFuture.
-
Method Summary
Modifier and TypeMethodDescriptionBlock the calling thread until the run finishes (drains or is cancelled) and return its final result.voidcancel()Cancel the run.booleanfinished()voidonComplete(CompletionHandler handler) Register a callback to be invoked once when the run finishes (drains or is cancelled), without blocking.voidpause()Pause the run: stop sending new requests.voidresume()Resume apausedrun.
-
Method Details
-
pause
void pause()Pause the run: stop sending new requests. Requests already in flight are allowed to finish. Has no effect if the run has already finished. Resume withresume(). -
resume
void resume()Resume apausedrun. Has no effect if the run is not paused or has already finished. -
cancel
void cancel()Cancel the run. No further requests are scheduled; requests already in flight are allowed to finish, after which the run completes with the partial results. Requests abandoned before they were sent are recorded withRequestStatus.DROPPED. -
finished
boolean finished()- Returns:
trueonce every queued request has finished or the run has been cancelled.
-
awaitCompletion
RequestExecutionResult awaitCompletion()Block the calling thread until the run finishes (drains or is cancelled) and return its final result. Returns immediately if the run has already finished.- Returns:
- The run's
RequestExecutionResult.
-
onComplete
Register a callback to be invoked once when the run finishes (drains or is cancelled), without blocking. If the run has already finished, the handler is invoked immediately.- Parameters:
handler- The handler to invoke with the finalRequestExecutionResult.
-