pub struct PipelineContext { /* private fields */ }Expand description
The per-delivery context of a .pipeline() subscription: the delivery’s round and the
broker’s connection pool.
Only a pipelined subscription’s delivery builds it, which is what makes Ctx<keys::Pipeline>
a compile error on a mount site without .pipeline().
§Examples
use ruststream_fred::stream::prelude::*;
#[subscriber(RedisStream::new("orders").group("workers"))]
async fn work(order: &Order, ctx: &mut Context<'_, PipelineContext>) -> HandlerOutcome {
let key = format!("orders.seen:{}", order.id);
if ctx.context(keys::Pipeline).incr(key).await.is_err() {
return HandlerOutcome::retry();
}
HandlerOutcome::ack()
}
fn app() -> RustStream {
RustStream::new(AppInfo::new("orders", "0.1.0")).with_broker(
RedisBroker::standalone("redis://localhost:6379"),
|b| {
b.include(work.pipeline());
},
)
}Implementations§
Trait Implementations§
Source§impl<F: Form> BuildBatchContext<RoundMessage<F>> for PipelineContext
A batch of a .pipeline() subscription is one segment: its context hands the batch body the
round every delivery of the batch shares.
impl<F: Form> BuildBatchContext<RoundMessage<F>> for PipelineContext
A batch of a .pipeline() subscription is one segment: its context hands the batch body the
round every delivery of the batch shares.
Source§fn build(first: &RoundMessage<F>) -> Self
fn build(first: &RoundMessage<F>) -> Self
Builds the context value by reading subscription-scoped fields out of the batch’s first
delivery, or out of the batch itself where it lends its values as one slice.
Source§impl<F: Form> BuildContext<RoundMessage<F>> for PipelineContext
impl<F: Form> BuildContext<RoundMessage<F>> for PipelineContext
Source§fn build(msg: &RoundMessage<F>) -> Self
fn build(msg: &RoundMessage<F>) -> Self
Builds the context value by reading fields out of
msg.Source§impl Clone for PipelineContext
impl Clone for PipelineContext
Source§impl Debug for PipelineContext
impl Debug for PipelineContext
Source§impl Field<PipelineContext> for Pipeline
impl Field<PipelineContext> for Pipeline
Source§type Value<'a> = &'a RedisPipeline
type Value<'a> = &'a RedisPipeline
The value read through this key, borrowed from the source for
'a.Source§fn get(self, src: &PipelineContext) -> &RedisPipeline
fn get(self, src: &PipelineContext) -> &RedisPipeline
Reads this key’s field out of
src.Source§impl Field<PipelineContext> for FredPool
impl Field<PipelineContext> for FredPool
Source§impl<State: Sync> FromContext<PipelineContext, State> for Ctx<FredPool>
Ctx<keys::FredPool> beside Ctx<keys::Pipeline>: the handler’s context is
PipelineContext there.
impl<State: Sync> FromContext<PipelineContext, State> for Ctx<FredPool>
Ctx<keys::FredPool> beside Ctx<keys::Pipeline>: the handler’s context is
PipelineContext there.
Source§type Rejection = !
type Rejection = !
The error returned when extraction fails. It is converted into a
HandlerOutcome (the
reflexive conversion makes HandlerOutcome itself a valid rejection, and Infallible
works for an extractor that never fails) and the delivery is settled by that outcome,
skipping the handler body.Source§fn from_context(
ctx: &mut Context<'_, PipelineContext, State>,
) -> impl Future<Output = Result<Self, Infallible>> + Send
fn from_context( ctx: &mut Context<'_, PipelineContext, State>, ) -> impl Future<Output = Result<Self, Infallible>> + Send
Resolves the value from the delivery context. The context is borrowed mutably so an
extractor may also read broker fields or take scratch a middleware left for it. Read more
Auto Trait Implementations§
impl !RefUnwindSafe for PipelineContext
impl !UnwindSafe for PipelineContext
impl Freeze for PipelineContext
impl Send for PipelineContext
impl Sync for PipelineContext
impl Unpin for PipelineContext
impl UnsafeUnpin for PipelineContext
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
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,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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