Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/launchdarkly/rust-eventsource-client
Server-sent events (SSE) client implementation for Rust
https://github.com/launchdarkly/rust-eventsource-client
eventsource feature-flags feature-toggles launchdarkly launchdarkly-sdk launchdarkly-sdk-component managed-by-terraform rust server-sent-events
Last synced: about 2 months ago
JSON representation
Server-sent events (SSE) client implementation for Rust
- Host: GitHub
- URL: https://github.com/launchdarkly/rust-eventsource-client
- Owner: launchdarkly
- License: other
- Created: 2019-07-17T21:54:56.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2024-08-12T19:45:09.000Z (5 months ago)
- Last Synced: 2024-11-17T11:03:42.352Z (2 months ago)
- Topics: eventsource, feature-flags, feature-toggles, launchdarkly, launchdarkly-sdk, launchdarkly-sdk-component, managed-by-terraform, rust, server-sent-events
- Language: Rust
- Homepage: https://docs.rs/eventsource-client/latest/eventsource_client/
- Size: 295 KB
- Stars: 72
- Watchers: 36
- Forks: 23
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
- Codeowners: CODEOWNERS
- Security: SECURITY.md
Awesome Lists containing this project
README
# eventsource-client
[![Run CI](https://github.com/launchdarkly/rust-eventsource-client/actions/workflows/ci.yml/badge.svg)](https://github.com/launchdarkly/rust-eventsource-client/actions/workflows/ci.yml)
Client for the [Server-Sent Events] protocol (aka [EventSource]).
[Server-Sent Events]: https://html.spec.whatwg.org/multipage/server-sent-events.html
[EventSource]: https://developer.mozilla.org/en-US/docs/Web/API/EventSource## Requirements
Requires tokio.
## Usage
Example that just prints the type of each event received:
```rust
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.)[examples directory]: https://github.com/launchdarkly/rust-eventsource-client/tree/main/eventsource-client/examples
## 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.## Minimum Supported Rust Version
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.