pub struct ConcurrentSessionManager { /* private fields */ }Expand description
并发安全会话管理器
使用读写分离锁,读操作可并发,写操作互斥。
Implementations§
Source§impl ConcurrentSessionManager
impl ConcurrentSessionManager
Sourcepub fn default_config() -> Self
pub fn default_config() -> Self
使用默认配置创建
Sourcepub fn get_state_sync(&self, id: &SessionId) -> Option<AgentState>
pub fn get_state_sync(&self, id: &SessionId) -> Option<AgentState>
同步获取会话状态(用于 AgentRuntime::status 同步方法)
Trait Implementations§
Source§impl Default for ConcurrentSessionManager
impl Default for ConcurrentSessionManager
Source§impl SessionManagerTrait for ConcurrentSessionManager
impl SessionManagerTrait for ConcurrentSessionManager
Source§fn create<'life0, 'async_trait>(
&'life0 self,
config: SessionConfig,
) -> Pin<Box<dyn Future<Output = Layer2Result<SessionId>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn create<'life0, 'async_trait>(
&'life0 self,
config: SessionConfig,
) -> Pin<Box<dyn Future<Output = Layer2Result<SessionId>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
创建新会话 Read more
Source§fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 SessionId,
) -> Pin<Box<dyn Future<Output = Layer2Result<Option<Session>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 SessionId,
) -> Pin<Box<dyn Future<Output = Layer2Result<Option<Session>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
获取会话 Read more
Source§fn get_or_create<'life0, 'life1, 'async_trait>(
&'life0 self,
id: Option<&'life1 SessionId>,
config: SessionConfig,
) -> Pin<Box<dyn Future<Output = Layer2Result<SessionId>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_or_create<'life0, 'life1, 'async_trait>(
&'life0 self,
id: Option<&'life1 SessionId>,
config: SessionConfig,
) -> Pin<Box<dyn Future<Output = Layer2Result<SessionId>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
获取或创建会话 Read more
Source§fn save<'life0, 'life1, 'async_trait>(
&'life0 self,
session: &'life1 Session,
) -> Pin<Box<dyn Future<Output = Layer2Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn save<'life0, 'life1, 'async_trait>(
&'life0 self,
session: &'life1 Session,
) -> Pin<Box<dyn Future<Output = Layer2Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
保存会话状态 Read more
Source§fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 SessionId,
) -> Pin<Box<dyn Future<Output = Layer2Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 SessionId,
) -> Pin<Box<dyn Future<Output = Layer2Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
删除会话 Read more
Source§fn list<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Layer2Result<Vec<SessionMeta>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn list<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Layer2Result<Vec<SessionMeta>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
列出所有会话 Read more
Source§fn update<'life0, 'life1, 'async_trait, F>(
&'life0 self,
id: &'life1 SessionId,
update_fn: F,
) -> Pin<Box<dyn Future<Output = Layer2Result<bool>> + Send + 'async_trait>>
fn update<'life0, 'life1, 'async_trait, F>( &'life0 self, id: &'life1 SessionId, update_fn: F, ) -> Pin<Box<dyn Future<Output = Layer2Result<bool>> + Send + 'async_trait>>
更新会话状态(带写锁) Read more
Source§fn read<'life0, 'life1, 'async_trait, F, T>(
&'life0 self,
id: &'life1 SessionId,
read_fn: F,
) -> Pin<Box<dyn Future<Output = Layer2Result<Option<T>>> + Send + 'async_trait>>
fn read<'life0, 'life1, 'async_trait, F, T>( &'life0 self, id: &'life1 SessionId, read_fn: F, ) -> Pin<Box<dyn Future<Output = Layer2Result<Option<T>>> + Send + 'async_trait>>
读取会话状态(带读锁) Read more
Source§fn get_state<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 SessionId,
) -> Pin<Box<dyn Future<Output = Layer2Result<Option<AgentState>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_state<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 SessionId,
) -> Pin<Box<dyn Future<Output = Layer2Result<Option<AgentState>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
获取会话状态
Source§fn set_state<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 SessionId,
state: AgentState,
) -> Pin<Box<dyn Future<Output = Layer2Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn set_state<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 SessionId,
state: AgentState,
) -> Pin<Box<dyn Future<Output = Layer2Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
设置会话状态
Source§fn add_message<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 SessionId,
message: Message,
) -> Pin<Box<dyn Future<Output = Layer2Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn add_message<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 SessionId,
message: Message,
) -> Pin<Box<dyn Future<Output = Layer2Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
添加消息到会话
Source§fn get_messages<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 SessionId,
) -> Pin<Box<dyn Future<Output = Layer2Result<Option<Vec<Message>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_messages<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 SessionId,
) -> Pin<Box<dyn Future<Output = Layer2Result<Option<Vec<Message>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
获取会话消息列表
Source§fn stats(&self) -> SessionStats
fn stats(&self) -> SessionStats
获取统计信息
Auto Trait Implementations§
impl !Freeze for ConcurrentSessionManager
impl !RefUnwindSafe for ConcurrentSessionManager
impl Send for ConcurrentSessionManager
impl Sync for ConcurrentSessionManager
impl Unpin for ConcurrentSessionManager
impl UnsafeUnpin for ConcurrentSessionManager
impl UnwindSafe for ConcurrentSessionManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more