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 any cancelCallback that is registered. Useful for integrating with libraries that support cancellation.

To perform cancellable async executions, use the FailsafeExecutor async methods.

  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    cancel(boolean mayInterruptIfRunning)
    Cancels a synchronous execution and calls the most recent cancelCallback that was registered.
    Executes the call until a successful result is returned or the configured policies are exceeded.
    boolean
    Returns whether the call has been cancelled.
  • Method Details

    • 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 recent cancelCallback that was registered. The execution is still allowed to complete and return a result. In addition to using a cancelCallback, executions can cooperate with cancellation by checking ExecutionContext.isCancelled().
      Parameters:
      mayInterruptIfRunning - whether the execution should be interrupted
      Returns:
      whether cancellation was successful or not. Returns false if the execution was already cancelled or completed.
    • isCancelled

      boolean isCancelled()
      Returns whether the call has been cancelled.