Trait ContextPromises

Source
pub trait ContextPromises<'ctx>: SealedContext<'ctx> {
    // Provided methods
    fn promise<T: Deserialize + 'static>(
        &'ctx self,
        key: &str,
    ) -> impl DurableFuture<Output = Result<T, TerminalError>> + 'ctx { ... }
    fn peek_promise<T: Deserialize + 'static>(
        &self,
        key: &str,
    ) -> impl Future<Output = Result<Option<T>, TerminalError>> + 'ctx { ... }
    fn resolve_promise<T: Serialize + 'static>(&self, key: &str, t: T) { ... }
    fn reject_promise(&self, key: &str, failure: TerminalError) { ... }
}
Expand description

Trait exposing Restate promise functionalities.

A promise is a durable, distributed version of a Rust oneshot channel. Restate keeps track of the promises 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.

Provided Methods§

Source

fn promise<T: Deserialize + 'static>( &'ctx self, key: &str, ) -> impl DurableFuture<Output = Result<T, TerminalError>> + 'ctx

Create a promise

Source

fn peek_promise<T: Deserialize + 'static>( &self, key: &str, ) -> impl Future<Output = Result<Option<T>, TerminalError>> + 'ctx

Peek a promise

Source

fn resolve_promise<T: Serialize + 'static>(&self, key: &str, t: T)

Resolve a promise

Source

fn reject_promise(&self, key: &str, failure: TerminalError)

Resolve a promise

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<'ctx, CTX: SealedContext<'ctx> + SealedCanUsePromises> ContextPromises<'ctx> for CTX