pub struct ProxyAwareSessionManager { /* private fields */ }Expand description
感知代理状态的 SessionManager
职责:
- 委托 LocalSessionManager 处理核心 session 逻辑
- 维护 session → backend_version 映射
- 在 resume 时检查版本一致性
- 版本不匹配时使 session 失效
Implementations§
Source§impl ProxyAwareSessionManager
impl ProxyAwareSessionManager
pub fn new(handler: Arc<ProxyHandler>) -> Self
Trait Implementations§
Source§impl SessionManager for ProxyAwareSessionManager
impl SessionManager for ProxyAwareSessionManager
type Error = LocalSessionManagerError
type Transport = WorkerTransport<LocalSessionWorker>
Source§async fn create_session(
&self,
) -> Result<(SessionId, Self::Transport), Self::Error>
async fn create_session( &self, ) -> Result<(SessionId, Self::Transport), Self::Error>
Create a new session and return its ID together with the transport
that will be used to exchange MCP messages within this session.
Source§async fn initialize_session(
&self,
id: &SessionId,
message: ClientJsonRpcMessage,
) -> Result<ServerJsonRpcMessage, Self::Error>
async fn initialize_session( &self, id: &SessionId, message: ClientJsonRpcMessage, ) -> Result<ServerJsonRpcMessage, Self::Error>
Forward the first message (the
initialize request) to the session.Source§async fn has_session(&self, id: &SessionId) -> Result<bool, Self::Error>
async fn has_session(&self, id: &SessionId) -> Result<bool, Self::Error>
Return
true if a session with the given ID exists and is active.Source§async fn close_session(&self, id: &SessionId) -> Result<(), Self::Error>
async fn close_session(&self, id: &SessionId) -> Result<(), Self::Error>
Close and remove the session. Corresponds to an HTTP DELETE request
with
Mcp-Session-Id.Source§async fn create_stream(
&self,
id: &SessionId,
message: ClientJsonRpcMessage,
) -> Result<impl Stream<Item = ServerSseMessage> + Send + 'static, Self::Error>
async fn create_stream( &self, id: &SessionId, message: ClientJsonRpcMessage, ) -> Result<impl Stream<Item = ServerSseMessage> + Send + 'static, Self::Error>
Route a client request into the session and return an SSE stream
carrying the server’s response(s).
Source§async fn accept_message(
&self,
id: &SessionId,
message: ClientJsonRpcMessage,
) -> Result<(), Self::Error>
async fn accept_message( &self, id: &SessionId, message: ClientJsonRpcMessage, ) -> Result<(), Self::Error>
Accept a notification, response, or error message from the client
without producing a response stream.
Source§async fn create_standalone_stream(
&self,
id: &SessionId,
) -> Result<impl Stream<Item = ServerSseMessage> + Send + 'static, Self::Error>
async fn create_standalone_stream( &self, id: &SessionId, ) -> Result<impl Stream<Item = ServerSseMessage> + Send + 'static, Self::Error>
Create an SSE stream not tied to a specific client request (HTTP GET).
Auto Trait Implementations§
impl !Freeze for ProxyAwareSessionManager
impl !RefUnwindSafe for ProxyAwareSessionManager
impl Send for ProxyAwareSessionManager
impl Sync for ProxyAwareSessionManager
impl Unpin for ProxyAwareSessionManager
impl UnsafeUnpin for ProxyAwareSessionManager
impl !UnwindSafe for ProxyAwareSessionManager
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