Package dev.restate.sdk
Interface DurablePromise<T>
public interface DurablePromise<T>
A
DurablePromise
is a durable, distributed version of a CompletableFuture
. Restate keeps track of the DurablePromise
across
restarts/failures.
You can use this feature to implement interaction between different workflow handlers, e.g. to send a signal from a shared handler to the workflow handler.
Use SharedWorkflowContext.promiseHandle(DurablePromiseKey)
to complete a durable
promise, either by DurablePromiseHandle.resolve(Object)
or DurablePromiseHandle.reject(String)
.
A DurablePromise
is tied to a single workflow execution and can only be resolved or
rejected while the workflow run is still ongoing. Once the workflow is cleaned up, all its
associated promises with their completions will be cleaned up as well.
NOTE: This interface MUST NOT be accessed concurrently since it can lead to different orderings of user actions, corrupting the execution of the invocation.
-
Method Summary
-
Method Details
-
awaitable
- Returns:
- the awaitable to await the promise on.
-
peek
- Returns:
- the value, if already present, otherwise returns an empty optional.
-