20 releases (13 breaking)

0.15.0 Mar 27, 2025
0.13.0 Jul 30, 2024
0.12.2 Dec 20, 2023
0.12.0 Nov 15, 2023
0.2.0 Jul 24, 2019

#25 in HTTP client

Download history 26938/week @ 2025-02-02 110942/week @ 2025-02-09 106207/week @ 2025-02-16 129263/week @ 2025-02-23 146581/week @ 2025-03-02 144939/week @ 2025-03-09 122610/week @ 2025-03-16 118117/week @ 2025-03-23 110913/week @ 2025-03-30 100774/week @ 2025-04-06 86312/week @ 2025-04-13 85421/week @ 2025-04-20 90302/week @ 2025-04-27 88799/week @ 2025-05-04 82683/week @ 2025-05-11 79211/week @ 2025-05-18

345,668 downloads per month
Used in 34 crates (19 directly)

Apache-2.0

300KB
1.5K SLoC

eventsource-client

Run CI

Client for the Server-Sent Events protocol (aka EventSource).

Requirements

Requires tokio.

Usage

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.)

Features

  • 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.

Stability

Early stage release for feedback purposes. May contain bugs or performance issues. API subject to change.

Dependencies

~5–15MB
~200K SLoC