Skip to main content

Module stream

Module stream 

Source
Expand description

The event stream runtime: one long-lived GET answered with text/event-stream, reconnected and resumed by itself.

It follows packages/sdk-codegen/streams/CONTRACT.md, and tests/api/stream_conformance.rs holds it to that contract with the scenarios every SDK shares.

EventStream is the stream: ask it for the next event, or turn it into a futures_util::Stream. Everything under it is public too, for a caller that drives the connection itself: the StreamTransport that opens a connection, the SseParser that reads one, and the StreamBudget that paces connects.

Structs§

ConnectRequest
The request one connect sends.
EventStream
An event stream. It connects, reads, reconnects with its cursor and waits between connects by itself, and stops only when it is closed or on a terminal StreamError.
HttpStreamTransport
The real transport: the client’s own reqwest client, key and project.
Reconnecting
The stream is not connected and will connect again.
Refused
An answer to a connect that is not the stream. The body is capped.
SseParser
Incremental parser of the event stream format.
StreamBudget
How many connects a rolling window allows. Clones share one count: every stream of one client draws on the same budget, so a caller that opens streams in a loop is paced like one that keeps a single stream.
StreamError
A terminal stream failure: the stream has stopped and connects no more, until EventStream::restart_after is called.
StreamEvent
One event of the stream: the same envelope a webhook carries.
StreamLimits
The stream’s sizes and counts.
StreamOptions
How one stream is run. Every field has a default: the stream’s own.
StreamRefusal
What one answer that is not the stream means.
StreamSpec
The description of a stream: what the generator read from its config.
StreamTiming
The stream’s times.

Enums§

Answer
What a connect came to, when it got an answer.
ReconnectReason
Why a connection ended or a connect failed, when the stream tries again.
SkipReason
Why a frame was dropped.
SseItem
What the parser found in the bytes it was fed.
StreamErrorKind
Why a stream ended for good. Everything else is retried and never an error.
StreamItem
Something a stream reports, in the order it happens.
StreamState
Where a stream is.

Traits§

StreamBody
The body of an open stream.
StreamTransport
Opens the stream. Err is a connect that got no answer: network, TLS.

Functions§

check_stream_url
Whether the stream can be read from url: Err says why not.

Type Aliases§

BoxFuture
A boxed future, as the transport traits return.
Jitter
A number in [0, 1), for the random part of a wait.
OnStatus
Called for every item that is not an event.