Skip to content

Commit bde88eb

Browse files
committed
feat: add distributed SSE event store
1 parent 8803d39 commit bde88eb

7 files changed

Lines changed: 479 additions & 45 deletions

File tree

crates/rmcp/Cargo.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,16 @@ required-features = [
414414
]
415415
path = "tests/test_streamable_http_session_store.rs"
416416

417+
[[test]]
418+
name = "test_streamable_http_event_store"
419+
required-features = [
420+
"client",
421+
"server",
422+
"transport-streamable-http-client-reqwest",
423+
"transport-streamable-http-server",
424+
]
425+
path = "tests/test_streamable_http_event_store.rs"
426+
417427
[[test]]
418428
name = "test_streamable_http_connection_reuse"
419429
required-features = [

crates/rmcp/src/transport/common/server_side_http.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,15 @@ impl ServerSseMessage {
119119
retry: Some(retry),
120120
}
121121
}
122+
123+
/// Create a retry hint without changing the client's last event ID.
124+
pub fn retry(retry: Duration) -> Self {
125+
Self {
126+
event_id: None,
127+
message: None,
128+
retry: Some(retry),
129+
}
130+
}
122131
}
123132

124133
pub(crate) fn sse_stream_response(

crates/rmcp/src/transport/streamable_http_server/session.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ pub mod local;
3232
pub mod never;
3333
pub mod store;
3434

35-
pub use store::{SessionState, SessionStore, SessionStoreError};
35+
pub use store::{
36+
EventId, EventStore, EventStoreError, EventStream, SessionState, SessionStore,
37+
SessionStoreError, StreamId,
38+
};
3639

3740
/// Extension marker inserted into the `initialize` request extensions during a
3841
/// session restore replay. Handlers can check for its presence to distinguish a
@@ -151,4 +154,9 @@ pub trait SessionManager: Send + Sync + 'static {
151154
) -> impl Future<Output = Result<RestoreOutcome<Self::Transport>, Self::Error>> + Send {
152155
futures::future::ready(Ok(RestoreOutcome::NotSupported))
153156
}
157+
158+
/// Return whether event IDs are assigned by an external event store.
159+
fn uses_external_event_store(&self) -> bool {
160+
false
161+
}
154162
}

0 commit comments

Comments
 (0)