pub struct StreamManager { /* private fields */ }
Expand description
Enhanced stream manager with resumability support (MCP spec compliant)
Implementations§
Source§impl StreamManager
impl StreamManager
Sourcepub fn new(storage: Arc<BoxedSessionStorage>) -> Self
pub fn new(storage: Arc<BoxedSessionStorage>) -> Self
Create new stream manager with session storage backend
Sourcepub fn with_config(
storage: Arc<BoxedSessionStorage>,
config: StreamConfig,
) -> Self
pub fn with_config( storage: Arc<BoxedSessionStorage>, config: StreamConfig, ) -> Self
Create stream manager with custom configuration
Sourcepub async fn handle_sse_connection(
&self,
session_id: String,
connection_id: ConnectionId,
last_event_id: Option<u64>,
) -> Result<Response<UnsyncBoxBody<Bytes, Error>>, StreamError>
pub async fn handle_sse_connection( &self, session_id: String, connection_id: ConnectionId, last_event_id: Option<u64>, ) -> Result<Response<UnsyncBoxBody<Bytes, Error>>, StreamError>
Handle SSE connection request with proper resumability
Sourcepub async fn unregister_connection(
&self,
session_id: &str,
connection_id: &ConnectionId,
)
pub async fn unregister_connection( &self, session_id: &str, connection_id: &ConnectionId, )
Remove a connection when it’s closed
Sourcepub async fn broadcast_to_session(
&self,
session_id: &str,
event_type: String,
data: Value,
) -> Result<u64, StreamError>
pub async fn broadcast_to_session( &self, session_id: &str, event_type: String, data: Value, ) -> Result<u64, StreamError>
Send event to specific session (MCP compliant - ONE connection only)
Sourcepub async fn broadcast_to_all_sessions(
&self,
event_type: String,
data: Value,
) -> Result<Vec<String>, StreamError>
pub async fn broadcast_to_all_sessions( &self, event_type: String, data: Value, ) -> Result<Vec<String>, StreamError>
Broadcast to all sessions (for server-wide notifications)
Sourcepub async fn cleanup_connections(&self) -> usize
pub async fn cleanup_connections(&self) -> usize
Clean up closed connections
Sourcepub async fn create_post_sse_stream(
&self,
session_id: String,
response: JsonRpcResponse,
) -> Result<Response<Full<Bytes>>, StreamError>
pub async fn create_post_sse_stream( &self, session_id: String, response: JsonRpcResponse, ) -> Result<Response<Full<Bytes>>, StreamError>
Create SSE stream for POST requests (MCP Streamable HTTP)
Sourcepub async fn get_stats(&self) -> StreamStats
pub async fn get_stats(&self) -> StreamStats
Get statistics about active streams
Trait Implementations§
Auto Trait Implementations§
impl Freeze for StreamManager
impl !RefUnwindSafe for StreamManager
impl Send for StreamManager
impl Sync for StreamManager
impl Unpin for StreamManager
impl !UnwindSafe for StreamManager
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