Skip to main content

Module stream_util

Module stream_util 

Source
Expand description

Shared, dependency-light helpers for chunked HTTP streaming and retry backoff, used by every reqwest-based provider.

These helpers were previously copy-pasted into the daimon crate’s built-in providers and into each external provider crate (daimon-provider-gemini, daimon-provider-azure). They could not live in a shared location before because the copies were tangled together with reqwest-specific header parsing, and daimon-core deliberately does not depend on reqwest.

Everything here is std-only. The reqwest-aware Retry-After header wrapper stays in each provider crate and delegates to parse_retry_after_secs.

Structs§

LineBuffer
Accumulates raw stream bytes and yields complete newline-terminated lines.

Constants§

BASE_DELAY_MS
Base delay for the first retry, in milliseconds.
MAX_DELAY_MS
Upper bound on the exponential term (before jitter), in milliseconds.

Functions§

backoff_delay
Computes the delay to wait before the next retry attempt.
full_jitter
Returns a pseudo-random value in [0, cap_ms].
parse_retry_after_secs
Parses a Retry-After value expressed in integer seconds.