faucet-source-websocket
A WebSocket streaming source: connects to a ws:///wss:// endpoint,
optionally sends subscription frames, and streams each incoming message as a
record until max_messages, idle_timeout, or Ctrl-C ends the run.
Part of the faucet-stream ecosystem.
Installation
[]
= "1.0"
= { = "1", = ["full"] }
Or via the umbrella crate:
= { = "1.0", = ["source-websocket"] }
Quick Start — Binance trade stream
use ;
use Source;
async
Config
| Field | Type | Default | Notes |
|---|---|---|---|
url |
string | — | ws:// or wss://; supports {ctx} substitution |
auth |
enum | none |
none / bearer{token} / custom{headers} |
subscribe_messages |
string[] | [] |
Sent in order on every (re)connect |
message_format |
enum | json |
json / raw_string / binary (base64) |
on_parse_error |
enum | fail |
fail / skip (json mode) |
envelope |
bool | false |
true → {data,received_at,url} |
ping_interval |
secs | — | Client keepalive ping |
max_messages |
int | — | At least one of max_messages/idle_timeout required |
idle_timeout |
secs | — | Stop after this long with no frame received. Reset by any inbound frame — data, ping/pong, or a frame dropped by on_parse_error=skip — so a live server streaming skippable frames does not trip it. Also caps outages |
reconnect |
bool | false |
Reconnect on drop / non-1000 close |
reconnect_backoff |
secs | 1 |
Fixed wait between attempts |
max_reconnect_attempts |
int | — | Cap consecutive failures (None = unlimited) |
max_message_bytes |
int | — | Bound frame/message size |
batch_size |
int | 1000 |
Records per StreamPage; 0 = one page |
Behavior
- Streaming:
stream_pagesyields a page eachbatch_sizerecords; the sink receives data continuously throughout the run. - Not resumable: a live feed has no replayable offset, so there is no state/bookmark — on reconnect the source resubscribes to the live stream.
- Termination:
max_messages,idle_timeout, Ctrl-C, or a clean1000close withreconnect=false.
License
MIT OR Apache-2.0