17 releases (10 breaking)

0.12.2 Dec 20, 2023
0.12.0 Nov 15, 2023
0.11.0 Nov 7, 2022
0.10.1 Apr 14, 2022
0.2.0 Jul 24, 2019

#31 in HTTP client

Download history 10125/week @ 2024-01-05 8612/week @ 2024-01-12 10252/week @ 2024-01-19 11592/week @ 2024-01-26 10239/week @ 2024-02-02 10224/week @ 2024-02-09 9630/week @ 2024-02-16 9805/week @ 2024-02-23 13044/week @ 2024-03-01 10509/week @ 2024-03-08 11966/week @ 2024-03-15 12907/week @ 2024-03-22 11754/week @ 2024-03-29 11960/week @ 2024-04-05 12458/week @ 2024-04-12 9652/week @ 2024-04-19

48,373 downloads per month
Used in 13 crates (8 directly)

Apache-2.0

295KB
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–16MB
~208K SLoC