diff --git a/Cargo.toml b/Cargo.toml index 649e120..4672b43 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,7 @@ tracing = "0.1" tracing-subscriber = { version = "0.3", features = ["env-filter"] } tower-http = { version = "0.4.4", features = ["full"] } ructe.workspace = true -tokio-stream = { version = "0.1.14", features = ["sync"] } +tokio-stream = { version = "0.1.14", features = ["sync", "time"] } futures-util = "0.3.28" diesel = { version = "2.1.0", features = ["chrono"] } diesel-async = { version = "0.4.1", features = ["mysql", "deadpool"] } diff --git a/src/api.rs b/src/api.rs index 84b8b2f..990df5b 100644 --- a/src/api.rs +++ b/src/api.rs @@ -1,3 +1,5 @@ +use std::time::Duration; + use axum::{ extract::{Path, State}, response::{ @@ -182,7 +184,8 @@ async fn ada_subscribe( State(state): State, ) -> Sse>> { let stream = BroadcastStream::new(state.sse_handler.ada_sender.subscribe()) - .map(|r| r.map(|s| Event::default().event("ada").data(s))); + .map(|r| r.map(|s| Event::default().event("ada").data(s))) + .throttle(Duration::from_secs(1)); Sse::new(stream).keep_alive(KeepAlive::default()) }