Skip to main content

StateStore

Trait StateStore 

Source
pub trait StateStore {
    // Required methods
    fn context_fetch(
        &self,
        user_pubkey: &str,
    ) -> Result<UserContext, StateError>;
    fn context_push(&self, context: UserContext) -> Result<(), StateError>;
    fn context_batch_fetch(
        &self,
        user_pubkeys: &[String],
    ) -> Result<Vec<UserContext>, StateError>;
    fn context_patch(
        &self,
        user_pubkey: &str,
        path: &str,
        value: Value,
    ) -> Result<(), StateError>;
    fn push_event(
        &self,
        user_pubkey: &str,
        event: ContextEvent,
    ) -> Result<(), StateError>;
    fn get_or_init(&self, user_pubkey: &str) -> Result<UserContext, StateError>;
}
Expand description

State storage backend trait Can be backed by DynamoDB, Redis, or Solana account data

Required Methods§

Source

fn context_fetch(&self, user_pubkey: &str) -> Result<UserContext, StateError>

Fetch user context (<100ms target)

Source

fn context_push(&self, context: UserContext) -> Result<(), StateError>

Push updated context (with optimistic locking)

Source

fn context_batch_fetch( &self, user_pubkeys: &[String], ) -> Result<Vec<UserContext>, StateError>

Fetch multiple users (for batch operations)

Source

fn context_patch( &self, user_pubkey: &str, path: &str, value: Value, ) -> Result<(), StateError>

Update specific field without full fetch/push

Source

fn push_event( &self, user_pubkey: &str, event: ContextEvent, ) -> Result<(), StateError>

Add event to recent events (ring buffer)

Source

fn get_or_init(&self, user_pubkey: &str) -> Result<UserContext, StateError>

Get or initialize context for new user

Implementors§