Class Awaitable<T>

  • Type Parameters:
    T - type of the awaitable result
    Direct Known Subclasses:
    AnyAwaitable, Awakeable

    @NotThreadSafe
    public class Awaitable<T>
    extends java.lang.Object
    An Awaitable allows to await an asynchronous result. Once await() is called, the execution stops until the asynchronous result is available.

    The result can be either a success or a failure. In case of a failure, await() will throw a TerminalException.

    • Method Detail

      • await

        public T await()
                throws dev.restate.sdk.common.TerminalException
        Wait for the current awaitable to complete. Executing this method may trigger the suspension of the function.

        NOTE: You should never wrap this invocation in a try-catch catching RuntimeException, as it will catch AbortedExecutionException as well.

        Throws:
        dev.restate.sdk.common.TerminalException - if the awaitable is ready and contains a failure
      • await

        public T await​(java.time.Duration timeout)
                throws dev.restate.sdk.common.TerminalException,
                       java.util.concurrent.TimeoutException
        Same as await(), but throws a TimeoutException if this Awaitable doesn't complete before the provided timeout.
        Throws:
        dev.restate.sdk.common.TerminalException
        java.util.concurrent.TimeoutException