15 releases (breaking)

0.12.0 Nov 15, 2023
0.11.0 Nov 7, 2022
0.10.2 Oct 28, 2022
0.10.1 Apr 14, 2022
0.2.0 Jul 24, 2019

#25 in HTTP client

Download history 12328/week @ 2023-08-11 12490/week @ 2023-08-18 12153/week @ 2023-08-25 9389/week @ 2023-09-01 10410/week @ 2023-09-08 10965/week @ 2023-09-15 10022/week @ 2023-09-22 11331/week @ 2023-09-29 14061/week @ 2023-10-06 10045/week @ 2023-10-13 12028/week @ 2023-10-20 12079/week @ 2023-10-27 10528/week @ 2023-11-03 9593/week @ 2023-11-10 8440/week @ 2023-11-17 7411/week @ 2023-11-24

38,320 downloads per month
Used in 12 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
~205K SLoC