Struct Http1BodyDrainConfig
pub struct Http1BodyDrainConfig {
pub max_bytes: usize,
pub timeout: Duration,
pub max_concurrent: NonZero<usize>,
}dns and http-backend and http and std and tcp only.Expand description
Configuration of the bounded background draining of HTTP/1 response bodies that were dropped before their end.
An HTTP/1 connection can only be reused once the previous response body was read off the wire. When a response from a pooled HTTP/1 connection is dropped with its body unread or partially read, the remainder is read and discarded by a background task, within these bounds, so the connection can return to the pool instead of being closed. While it drains, the connection stays checked out: requests meanwhile are served as the pool’s saturation policy decides (another connection, or waiting for one). A successful drain makes the connection available to later requests; it does not reserve it for the next one.
A drain gives up, closing the connection as without draining, once:
- more than
max_bytespayload bytes were discarded with more of the body left. The body is read a frame at a time, so the last frame read may cross the limit: this bounds the reads, not exactly the bytes read off the socket. A body ending at exactlymax_bytesdrains, as does one whose final frame crosses it; timeoutelapsed since the body was dropped, including the time waiting to be scheduled;- the body fails (truncated or malformed framing), or the executor shuts down.
Draining only starts if fewer than max_concurrent
drains run for the same connector (shared by its clones); otherwise the
connection is closed right away. A zero max_bytes or timeout never
drains a body that has bytes left.
This only applies to HTTP/1 responses whose connection could be reused:
not after a Connection: close (sent or received), for close-delimited
bodies, upgrades or successful CONNECT tunnels, nor for connections
otherwise known broken or not reusable. HTTP/2 and HTTP/3 cancel the
stream of a dropped body instead, keeping the connection.
Draining needs the tokio runtime of the connection: a body dropped outside of one is not drained.
Fields§
§max_bytes: usizeAt most this many unread payload bytes (before content decoding) are discarded to recover a connection: 1 MiB by default.
timeout: DurationA drain gives up this long after the body was dropped: 50 ms by default.
max_concurrent: NonZero<usize>At most this many drains run at once per connector: 256 by default.
Implementations§
§impl Http1BodyDrainConfig
impl Http1BodyDrainConfig
pub const fn new() -> Http1BodyDrainConfig
pub const fn new() -> Http1BodyDrainConfig
Create a new Http1BodyDrainConfig with the default limits.
pub fn with_max_bytes(self, max: usize) -> Http1BodyDrainConfig
pub fn with_max_bytes(self, max: usize) -> Http1BodyDrainConfig
Discard at most this many unread payload bytes to recover a connection.
pub fn set_max_bytes(&mut self, max: usize) -> &mut Http1BodyDrainConfig
pub fn set_max_bytes(&mut self, max: usize) -> &mut Http1BodyDrainConfig
Discard at most this many unread payload bytes to recover a connection.
pub fn with_timeout(self, timeout: Duration) -> Http1BodyDrainConfig
pub fn with_timeout(self, timeout: Duration) -> Http1BodyDrainConfig
Give up a drain this long after its body was dropped.
pub fn set_timeout(&mut self, timeout: Duration) -> &mut Http1BodyDrainConfig
pub fn set_timeout(&mut self, timeout: Duration) -> &mut Http1BodyDrainConfig
Give up a drain this long after its body was dropped.
pub fn with_max_concurrent(self, max: NonZero<usize>) -> Http1BodyDrainConfig
pub fn with_max_concurrent(self, max: NonZero<usize>) -> Http1BodyDrainConfig
Run at most this many drains at once per connector.
pub fn set_max_concurrent(
&mut self,
max: NonZero<usize>,
) -> &mut Http1BodyDrainConfig
pub fn set_max_concurrent( &mut self, max: NonZero<usize>, ) -> &mut Http1BodyDrainConfig
Run at most this many drains at once per connector.
Trait Implementations§
§impl Clone for Http1BodyDrainConfig
impl Clone for Http1BodyDrainConfig
§fn clone(&self) -> Http1BodyDrainConfig
fn clone(&self) -> Http1BodyDrainConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for Http1BodyDrainConfig
impl Debug for Http1BodyDrainConfig
§impl Default for Http1BodyDrainConfig
impl Default for Http1BodyDrainConfig
§fn default() -> Http1BodyDrainConfig
fn default() -> Http1BodyDrainConfig
impl Eq for Http1BodyDrainConfig
§impl PartialEq for Http1BodyDrainConfig
impl PartialEq for Http1BodyDrainConfig
impl StructuralPartialEq for Http1BodyDrainConfig
Auto Trait Implementations§
impl Freeze for Http1BodyDrainConfig
impl RefUnwindSafe for Http1BodyDrainConfig
impl Send for Http1BodyDrainConfig
impl Sync for Http1BodyDrainConfig
impl Unpin for Http1BodyDrainConfig
impl UnsafeUnpin for Http1BodyDrainConfig
impl UnwindSafe for Http1BodyDrainConfig
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a rama_grpc::Request§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Policy that returns Action::Follow only if self and other return
Action::Follow. Read more