Skip to main content

Module idle

Module idle 

Source
Expand description

Body wrappers for streaming upstream responses.

Both operate at the http_body::Body frame level so they compose with any BoxBody<Bytes, BoxError> — the streaming body type used throughout src/outbound and src/context/stream.rs — without re-buffering it. BoxError (crate::outbound::BoxError) is a boxed std::error::Error, not hyper::Error: see that type alias’s doc comment for why. In short, hyper::Error has no public constructor anywhere in the hyper crate, so a body wrapper built on it could never report its own failure. BoxError has no such restriction, which is what lets idle_timeout_body below actually error the stream on reap, rather than merely ending it.

Structs§

BodyHolding 🔒
IdleTimeoutBody 🔒
IdleTimeoutError
The error idle_timeout_body reports when a stream is reaped: no frame arrived for the configured idle bound.

Functions§

body_holding
Wraps body so guards are dropped only when the body reports it has finished (cleanly or with an error) or the returned body is itself dropped — never merely because the node that started the stream returned. This is what keeps balancer in-flight counters and limit-conn permits held for the stream’s real lifetime.
idle_timeout_body
Wraps body so it errors when no frame arrives for idle. The timer resets on every frame, so a steady stream survives indefinitely while a silent one is reaped — and reaped as a real failure (Poll::Ready(Some(Err(IdleTimeoutError)))), not a clean end: ending cleanly would write the chunked terminator (HTTP/1.1) or END_STREAM (h2) exactly as a legitimately complete response would, making a truncated body indistinguishable from a complete one on the wire — on exactly the unbounded bodies (NDJSON exports, log tails, bulk proxied data) this feature targets. A real upstream error — the wrapped body itself yielding Err, e.g. a connection reset — is forwarded unchanged; the reap only fires when nothing else has.