pub struct SessionManager { /* private fields */ }Expand description
Manages multiple concurrent sessions
Implementations§
Source§impl SessionManager
impl SessionManager
Sourcepub fn new(store: Arc<dyn SessionStore>, config: SessionManagerConfig) -> Self
pub fn new(store: Arc<dyn SessionStore>, config: SessionManagerConfig) -> Self
Create a new SessionManager
Sourcepub async fn create_session(
&self,
config: SessionConfig,
app_config: AppConfig,
) -> Result<(String, Sender<AppCommand>)>
pub async fn create_session( &self, config: SessionConfig, app_config: AppConfig, ) -> Result<(String, Sender<AppCommand>)>
Create a new session
Sourcepub async fn take_event_receiver(
&self,
session_id: &str,
) -> Result<Receiver<AppEvent>>
pub async fn take_event_receiver( &self, session_id: &str, ) -> Result<Receiver<AppEvent>>
Take the event receiver for a session (can only be called once per session)
Sourcepub async fn get_session(&self, session_id: &str) -> Result<Option<SessionInfo>>
pub async fn get_session(&self, session_id: &str) -> Result<Option<SessionInfo>>
Get session information
Sourcepub async fn get_session_workspace(
&self,
session_id: &str,
) -> Result<Option<Arc<dyn Workspace>>>
pub async fn get_session_workspace( &self, session_id: &str, ) -> Result<Option<Arc<dyn Workspace>>>
Get the workspace for a session
Sourcepub async fn resume_session(
&self,
session_id: &str,
app_config: AppConfig,
) -> Result<Sender<AppCommand>>
pub async fn resume_session( &self, session_id: &str, app_config: AppConfig, ) -> Result<Sender<AppCommand>>
Resume a session (load from storage and activate)
Sourcepub async fn suspend_session(&self, session_id: &str) -> Result<bool>
pub async fn suspend_session(&self, session_id: &str) -> Result<bool>
Suspend a session (save to storage and deactivate)
Sourcepub async fn delete_session(&self, session_id: &str) -> Result<bool>
pub async fn delete_session(&self, session_id: &str) -> Result<bool>
Delete a session permanently
Sourcepub async fn list_sessions(
&self,
filter: SessionFilter,
) -> Result<Vec<SessionInfo>>
pub async fn list_sessions( &self, filter: SessionFilter, ) -> Result<Vec<SessionInfo>>
List sessions with filtering
Sourcepub async fn get_active_sessions(&self) -> Vec<String>
pub async fn get_active_sessions(&self) -> Vec<String>
Get active session IDs
Sourcepub async fn is_session_active(&self, session_id: &str) -> bool
pub async fn is_session_active(&self, session_id: &str) -> bool
Check if a session is active
Sourcepub async fn send_command(
&self,
session_id: &str,
command: AppCommand,
) -> Result<()>
pub async fn send_command( &self, session_id: &str, command: AppCommand, ) -> Result<()>
Send a command to an active session
Sourcepub async fn update_session_state(
&self,
session_id: &str,
update_fn: impl FnOnce(&mut SessionState),
) -> Result<()>
pub async fn update_session_state( &self, session_id: &str, update_fn: impl FnOnce(&mut SessionState), ) -> Result<()>
Update session state and persist if auto-persist is enabled
Sourcepub async fn emit_event(&self, session_id: String, event: StreamEvent)
pub async fn emit_event(&self, session_id: String, event: StreamEvent)
Emit an event for a session
Sourcepub async fn cleanup_inactive_sessions(&self, max_idle_time: Duration) -> usize
pub async fn cleanup_inactive_sessions(&self, max_idle_time: Duration) -> usize
Cleanup inactive sessions
Sourcepub fn store(&self) -> &Arc<dyn SessionStore>
pub fn store(&self) -> &Arc<dyn SessionStore>
Get session store reference
Sourcepub async fn increment_subscriber_count(&self, session_id: &str) -> Result<()>
pub async fn increment_subscriber_count(&self, session_id: &str) -> Result<()>
Increment the subscriber count for a session
Sourcepub async fn decrement_subscriber_count(&self, session_id: &str) -> Result<()>
pub async fn decrement_subscriber_count(&self, session_id: &str) -> Result<()>
Decrement the subscriber count for a session
Sourcepub async fn touch_session(&self, session_id: &str) -> Result<()>
pub async fn touch_session(&self, session_id: &str) -> Result<()>
Touch a session to update its last activity timestamp
Sourcepub async fn maybe_suspend_idle_session(&self, session_id: &str) -> Result<()>
pub async fn maybe_suspend_idle_session(&self, session_id: &str) -> Result<()>
Check if a session should be suspended due to no subscribers
Sourcepub async fn get_session_state(
&self,
session_id: &str,
) -> Result<Option<SessionState>>
pub async fn get_session_state( &self, session_id: &str, ) -> Result<Option<SessionState>>
Get session state for gRPC responses
Sourcepub async fn get_mcp_statuses(
&self,
session_id: &str,
) -> Result<Vec<McpServerInfo>>
pub async fn get_mcp_statuses( &self, session_id: &str, ) -> Result<Vec<McpServerInfo>>
Get MCP server connection statuses for a session
Auto Trait Implementations§
impl Freeze for SessionManager
impl !RefUnwindSafe for SessionManager
impl Send for SessionManager
impl Sync for SessionManager
impl Unpin for SessionManager
impl !UnwindSafe for SessionManager
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request