pub struct ResponseStream {
body: BoxBody<Bytes, Box<dyn Error + Send + Sync>>,
guards: Mutex<Vec<Box<dyn Send + 'static>>>,
}Expand description
An upstream response body being relayed to the client unbuffered, plus any
guards whose lifetime must match the stream rather than the node that
produced it (balancer in-flight counters, limit-conn permits).
Fields§
§body: BoxBody<Bytes, Box<dyn Error + Send + Sync>>§guards: Mutex<Vec<Box<dyn Send + 'static>>>Implementations§
Source§impl ResponseStream
impl ResponseStream
pub fn new(body: BoxBody<Bytes, Box<dyn Error + Send + Sync>>) -> Self
Sourcepub fn hold(&mut self, guard: Box<dyn Send + 'static>)
pub fn hold(&mut self, guard: Box<dyn Send + 'static>)
Attaches a guard released when the stream is consumed or dropped.
Production code binds guards in at construction instead (see
upstream.rs’s use of body_holding); this is exercised directly by
this module’s own tests.
Sourcepub fn into_parts(
self,
) -> (BoxBody<Bytes, Box<dyn Error + Send + Sync>>, Vec<Box<dyn Send + 'static>>)
pub fn into_parts( self, ) -> (BoxBody<Bytes, Box<dyn Error + Send + Sync>>, Vec<Box<dyn Send + 'static>>)
Takes the body for transmission. The guards travel with the returned
Vec, not with self (which is consumed here) — the caller must keep
that Vec alive until the returned body has finished streaming to the
client; dropping it early releases the guards early.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ResponseStream
impl !RefUnwindSafe for ResponseStream
impl !UnwindSafe for ResponseStream
impl Send for ResponseStream
impl Sync for ResponseStream
impl Unpin for ResponseStream
impl UnsafeUnpin for ResponseStream
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
Mutably borrows from an owned value. Read more
§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>
Converts
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>
Converts
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