Package dev.failsafe
Interface Call<R>
-
- Type Parameters:
R- result type
- All Known Implementing Classes:
CallImpl
public interface Call<R>A call that can perform Failsafe executions and can be cancelled. Cancellations are propagated to anycancelCallbackthat is registered. Useful for integrating with libraries that support cancellation.To perform cancellable async executions, use the
FailsafeExecutorasync methods.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleancancel(boolean mayInterruptIfRunning)Cancels a synchronous execution and calls the most recentcancelCallbackthat was registered.Rexecute()Executes the call until a successful result is returned or the configured policies are exceeded.booleanisCancelled()Returns whether the call has been cancelled.
-
-
-
Method Detail
-
execute
R execute()
Executes the call until a successful result is returned or the configured policies are exceeded.- Throws:
FailsafeException- if the execution fails with a checked Exception.Throwable.getCause()can be used to learn the underlying checked exception.
-
cancel
boolean cancel(boolean mayInterruptIfRunning)
Cancels a synchronous execution and calls the most recentcancelCallbackthat was registered. The execution is still allowed to complete and return a result. In addition to using acancelCallback, executions can cooperate with cancellation by checkingExecutionContext.isCancelled().- Parameters:
mayInterruptIfRunning- whether the execution should be interrupted- Returns:
- whether cancellation was successful or not. Returns
falseif the execution was already cancelled or completed.
-
isCancelled
boolean isCancelled()
Returns whether the call has been cancelled.
-
-