pub struct Next<'a> { /* private fields */ }Expand description
The continuation an Interceptor calls to run the rest of the chain.
Next holds the still-to-run interceptors and the terminal handler.
run consumes it; not calling it short-circuits the chain.
Next is also Clone (two shared references) for the interceptor that
must run the rest of the chain more than once — a retry or a hedge.
Clone before the first run and copy the request with
UnaryRequest::try_clone:
ⓘ
let spare = req.try_clone()?; // ctx clone + Payload::try_clone
match next.clone().run(req).await {
Err(e) if e.code == ErrorCode::Unavailable => next.run(spare).await,
done => done,
}Re-running dispatches the inner interceptors and the terminal again.
On the server that means invoking the handler twice, so gate any
re-run on Spec::idempotency_level.
Every attempt shares the one request deadline (a retry cannot extend
it) and the one request tracing span; open a span per attempt if they
need to be observable separately.
Implementations§
Source§impl<'a> Next<'a>
impl<'a> Next<'a>
Sourcepub async fn run(self, req: UnaryRequest) -> Result<UnaryResponse, ConnectError>
pub async fn run(self, req: UnaryRequest) -> Result<UnaryResponse, ConnectError>
Trait Implementations§
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for Next<'a>
impl<'a> !UnwindSafe for Next<'a>
impl<'a> Freeze for Next<'a>
impl<'a> Send for Next<'a>
impl<'a> Sync for Next<'a>
impl<'a> Unpin for Next<'a>
impl<'a> UnsafeUnpin for Next<'a>
Blanket Implementations§
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