Skip to main content

SagaStateStore

Trait SagaStateStore 

Source
pub trait SagaStateStore:
    Send
    + Sync
    + 'static {
    // Required methods
    fn load<'life0, 'life1, 'async_trait>(
        &'life0 self,
        correlation_id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Option<Vec<u8>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn save<'life0, 'life1, 'async_trait>(
        &'life0 self,
        correlation_id: &'life1 str,
        payload: Vec<u8>,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn delete<'life0, 'life1, 'async_trait>(
        &'life0 self,
        correlation_id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn keys<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Vec<String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Per-correlation state storage. Saga state is opaque (Vec<u8>) at this layer; the saga supplies the codec via crate::saga::Saga::encode_state / crate::saga::Saga::decode_state.

Required Methods§

Source

fn load<'life0, 'life1, 'async_trait>( &'life0 self, correlation_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Option<Vec<u8>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Load the persisted state for correlation_id. None means no state exists yet (treat as fresh / Default).

Source

fn save<'life0, 'life1, 'async_trait>( &'life0 self, correlation_id: &'life1 str, payload: Vec<u8>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Persist payload as the latest state for correlation_id.

Source

fn delete<'life0, 'life1, 'async_trait>( &'life0 self, correlation_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Drop the state for correlation_id (called on SagaAction::Complete).

Source

fn keys<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Vec<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Every correlation id with persisted state — used at startup to rehydrate in-flight sagas.

Implementors§