atrium_api/agent/store/
memory.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
use super::{Session, SessionStore};
use std::sync::Arc;
use tokio::sync::RwLock;

#[derive(Default, Clone)]
pub struct MemorySessionStore {
    session: Arc<RwLock<Option<Session>>>,
}

impl SessionStore for MemorySessionStore {
    async fn get_session(&self) -> Option<Session> {
        self.session.read().await.clone()
    }
    async fn set_session(&self, session: Session) {
        self.session.write().await.replace(session);
    }
    async fn clear_session(&self) {
        self.session.write().await.take();
    }
}