https://github.com/caido/actix-sse
SSE implementation for Actix
https://github.com/caido/actix-sse
actix sse
Last synced: 10 months ago
JSON representation
SSE implementation for Actix
- Host: GitHub
- URL: https://github.com/caido/actix-sse
- Owner: caido
- License: mit
- Created: 2025-07-24T20:50:45.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-07-24T21:41:04.000Z (11 months ago)
- Last Synced: 2025-08-17T18:44:28.021Z (10 months ago)
- Topics: actix, sse
- Language: Rust
- Homepage:
- Size: 17.6 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# Actix SSE
[
](https://github.com/caido/actix-sse)
[
](https://crates.io/crates/actix-sse)
SSE implementation for Actix, extracted from [actix-web-lab](https://github.com/robjtede/actix-web-lab/) with minimal dependencies.
```rust
use std::{convert::Infallible, time::Duration};
#[get("/from-stream")]
async fn from_stream() -> impl Responder {
let event_stream = futures_util::stream::iter([Ok::<_, Infallible>(actix_sse::Event::Data(
actix_sse::Data::new("foo"),
))]);
actix_sse::Sse::from_stream(event_stream).with_keep_alive(Duration::from_secs(5))
}
```
## Migrating from actix-web-lab
This should mostly be a drop-in replacement for the `sse` module, but we did remove a few convenience methods.
- `Data::from_json`: Serialize in the caller and use `Data::new`
- `Data::set_id`: Use `Data::id`
- `Sse::from_receiver`: Use `Sse::from_stream(tokio_stream::wrappers::ReceiverStream::new(rx))`