Client for the Server-Sent Events protocol (aka EventSource).
Requires tokio.
Example that just prints the type of each event received:
use eventsource_client as es;
let mut client = es::ClientBuilder::for_url("https://example.com/stream")?
.header("Authorization", "Basic username:password")?
.build();
client
.stream()
.map_ok(|event| println!("got event: {:?}", event))
.map_err(|err| eprintln!("error streaming events: {:?}", err));
(Some boilerplate omitted for clarity; see examples directory for complete, working code.)
- tokio-based streaming client.
- Supports setting custom headers on the HTTP request (e.g. for endpoints requiring authorization).
- Retry for failed connections.
- Reconnection if connection is interrupted, with exponential backoff.
Early stage release for feedback purposes. May contain bugs or performance issues. API subject to change.
This project aims to maintain compatibility with a Rust version that is at least six months old.
Version updates may occur more frequently than the policy guideline states if external forces require it. For example, a CVE in a downstream dependency requiring an MSRV bump would be considered an acceptable reason to violate the six month guideline.