diff --git a/src/main.rs b/src/main.rs index ca2e00a..30f8262 100644 --- a/src/main.rs +++ b/src/main.rs @@ -96,7 +96,7 @@ async fn sse_handler( #[actix_web::main] async fn main() -> std::io::Result<()> { - let (tx, rx) = broadcast::channel(100); + let (tx, mut rx) = broadcast::channel(100); let redis_url = env::var("REDIS_URL").unwrap(); let client = redis::Client::open(redis_url).unwrap(); let _handle = tokio::spawn(async move { @@ -114,8 +114,9 @@ async fn main() -> std::io::Result<()> { }); HttpServer::new(move || { + let rx = tx.subscribe(); App::new() - .app_data(web::Data::new(rx.subscribe())) + .app_data(web::Data::new(rx)) .app_data(web::Data::new(client.clone())) .route("/aware/{token}", web::get().to(sse_handler)) })