greentic_session/
store.rs1use crate::ReplyScope;
2use crate::error::SessionResult;
3use greentic_types::{SessionData, SessionKey, TenantCtx, UserId};
4use std::time::Duration;
5
6pub trait SessionStore: Send + Sync + 'static {
12 fn create_session(&self, ctx: &TenantCtx, data: SessionData) -> SessionResult<SessionKey>;
14
15 fn get_session(&self, key: &SessionKey) -> SessionResult<Option<SessionData>>;
17
18 fn update_session(&self, key: &SessionKey, data: SessionData) -> SessionResult<()>;
20
21 fn remove_session(&self, key: &SessionKey) -> SessionResult<()>;
23
24 fn register_wait(
26 &self,
27 ctx: &TenantCtx,
28 user_id: &UserId,
29 scope: &ReplyScope,
30 session_key: &SessionKey,
31 data: SessionData,
32 ttl: Option<Duration>,
33 ) -> SessionResult<()>;
34
35 fn find_wait_by_scope(
37 &self,
38 ctx: &TenantCtx,
39 user_id: &UserId,
40 scope: &ReplyScope,
41 ) -> SessionResult<Option<SessionKey>>;
42
43 fn list_waits_for_user(
45 &self,
46 ctx: &TenantCtx,
47 user_id: &UserId,
48 ) -> SessionResult<Vec<SessionKey>>;
49
50 fn clear_wait(
52 &self,
53 ctx: &TenantCtx,
54 user_id: &UserId,
55 scope: &ReplyScope,
56 ) -> SessionResult<()>;
57
58 #[deprecated(note = "use find_wait_by_scope or list_waits_for_user instead")]
60 fn find_by_user(
61 &self,
62 ctx: &TenantCtx,
63 user: &UserId,
64 ) -> SessionResult<Option<(SessionKey, SessionData)>>;
65}