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

#22 in HTTP client

Download history 12092/week @ 2024-12-24 16808/week @ 2024-12-31 26338/week @ 2025-01-07 22541/week @ 2025-01-14 26862/week @ 2025-01-21 25424/week @ 2025-01-28 28386/week @ 2025-02-04 111148/week @ 2025-02-11 123550/week @ 2025-02-18 132731/week @ 2025-02-25 141635/week @ 2025-03-04 149120/week @ 2025-03-11 119552/week @ 2025-03-18 119802/week @ 2025-03-25 103044/week @ 2025-04-01 85908/week @ 2025-04-08

448,978 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

~6–16MB
~212K SLoC