pub trait SessionStore:
Send
+ Sync
+ 'static {
// Required methods
fn create_session(
&self,
ctx: &TenantCtx,
data: SessionData,
) -> SessionResult<SessionKey>;
fn get_session(
&self,
key: &SessionKey,
) -> SessionResult<Option<SessionData>>;
fn update_session(
&self,
key: &SessionKey,
data: SessionData,
) -> SessionResult<()>;
fn remove_session(&self, key: &SessionKey) -> SessionResult<()>;
fn register_wait(
&self,
ctx: &TenantCtx,
user_id: &UserId,
scope: &ReplyScope,
session_key: &SessionKey,
data: SessionData,
ttl: Option<Duration>,
) -> SessionResult<()>;
fn find_wait_by_scope(
&self,
ctx: &TenantCtx,
user_id: &UserId,
scope: &ReplyScope,
) -> SessionResult<Option<SessionKey>>;
fn list_waits_for_user(
&self,
ctx: &TenantCtx,
user_id: &UserId,
) -> SessionResult<Vec<SessionKey>>;
fn clear_wait(
&self,
ctx: &TenantCtx,
user_id: &UserId,
scope: &ReplyScope,
) -> SessionResult<()>;
fn find_by_user(
&self,
ctx: &TenantCtx,
user: &UserId,
) -> SessionResult<Option<(SessionKey, SessionData)>>;
}Expand description
Persistent session storage interface used by Greentic runtimes.
SessionData captures the tenant context, flow identifier, cursor, and serialized execution
state snapshot for an in-flight flow. Implementations store that payload so runners can pause
execution, persist the snapshot, and resume the flow consistently after new input arrives.
Required Methods§
Sourcefn create_session(
&self,
ctx: &TenantCtx,
data: SessionData,
) -> SessionResult<SessionKey>
fn create_session( &self, ctx: &TenantCtx, data: SessionData, ) -> SessionResult<SessionKey>
Creates a new session associated with the supplied tenant context and returns its key.
Sourcefn get_session(&self, key: &SessionKey) -> SessionResult<Option<SessionData>>
fn get_session(&self, key: &SessionKey) -> SessionResult<Option<SessionData>>
Fetches the session payload for the provided key, if it exists.
Sourcefn update_session(
&self,
key: &SessionKey,
data: SessionData,
) -> SessionResult<()>
fn update_session( &self, key: &SessionKey, data: SessionData, ) -> SessionResult<()>
Replaces the session payload for the provided key.
Sourcefn remove_session(&self, key: &SessionKey) -> SessionResult<()>
fn remove_session(&self, key: &SessionKey) -> SessionResult<()>
Removes the session entry and clears any lookup indices.
Sourcefn register_wait(
&self,
ctx: &TenantCtx,
user_id: &UserId,
scope: &ReplyScope,
session_key: &SessionKey,
data: SessionData,
ttl: Option<Duration>,
) -> SessionResult<()>
fn register_wait( &self, ctx: &TenantCtx, user_id: &UserId, scope: &ReplyScope, session_key: &SessionKey, data: SessionData, ttl: Option<Duration>, ) -> SessionResult<()>
Registers a paused flow wait, persisting the session and routing indices.
Sourcefn find_wait_by_scope(
&self,
ctx: &TenantCtx,
user_id: &UserId,
scope: &ReplyScope,
) -> SessionResult<Option<SessionKey>>
fn find_wait_by_scope( &self, ctx: &TenantCtx, user_id: &UserId, scope: &ReplyScope, ) -> SessionResult<Option<SessionKey>>
Finds a wait registered for the provided scope, if one exists.
Sourcefn list_waits_for_user(
&self,
ctx: &TenantCtx,
user_id: &UserId,
) -> SessionResult<Vec<SessionKey>>
fn list_waits_for_user( &self, ctx: &TenantCtx, user_id: &UserId, ) -> SessionResult<Vec<SessionKey>>
Lists all waits registered for the provided user.
Sourcefn clear_wait(
&self,
ctx: &TenantCtx,
user_id: &UserId,
scope: &ReplyScope,
) -> SessionResult<()>
fn clear_wait( &self, ctx: &TenantCtx, user_id: &UserId, scope: &ReplyScope, ) -> SessionResult<()>
Clears a wait registration for the provided scope.
Sourcefn find_by_user(
&self,
ctx: &TenantCtx,
user: &UserId,
) -> SessionResult<Option<(SessionKey, SessionData)>>
👎Deprecated: use find_wait_by_scope or list_waits_for_user instead
fn find_by_user( &self, ctx: &TenantCtx, user: &UserId, ) -> SessionResult<Option<(SessionKey, SessionData)>>
use find_wait_by_scope or list_waits_for_user instead
Finds the active session bound to the specified tenant + user combination.