pub struct StreamContext { /* private fields */ }Expand description
Per-delivery context for a Redis Streams delivery (RedisMessage).
Built once per delivery from the message. Read its fields by keys key off a
ruststream::runtime::Context, or bind one as a handler parameter with the core
Ctx<K> extractor. A body that repositions its group names this type as its context and needs
nothing else: the keys::SeekHandle key carries the live handle.
§Examples
use ruststream_fred::stream::prelude::*;
/// Skips the group past a region the producer marked poisoned, and logs where it was.
#[subscriber(RedisStream::new("orders").group("workers"))]
async fn work(order: &Order, ctx: &mut Context<'_, StreamContext>) -> HandlerOutcome {
if order.id != 0 {
return HandlerOutcome::ack();
}
println!("poison marker at {}", ctx.context(keys::EntryId));
match ctx.context(keys::SeekHandle).seek(RedisGroupPosition::end()).await {
Ok(()) => HandlerOutcome::ack(),
Err(_) => HandlerOutcome::retry(),
}
}Implementations§
Source§impl StreamContext
impl StreamContext
Sourcepub const fn entry_id(&self) -> EntryId
pub const fn entry_id(&self) -> EntryId
The stream entry id (for example 1700000000000-0) this delivery was read at.
Sourcepub const fn position(&self) -> RedisGroupPosition
pub const fn position(&self) -> RedisGroupPosition
The group cursor that redelivers this entry, as Positioned
reports it: the cursor is exclusive, so it sits one id below the entry’s own.
Sourcepub fn consumer_group(&self) -> &str
pub fn consumer_group(&self) -> &str
The consumer group this delivery was read through.
Sourcepub const fn seeker(&self) -> &RedisGroupSeeker
pub const fn seeker(&self) -> &RedisGroupSeeker
The handle repositioning this delivery’s consumer group.
The cursor belongs to the group, so a seek through it moves every consumer of that group;
see RedisGroupSeeker.
Trait Implementations§
Source§impl BuildContext<RedisMessage> for StreamContext
impl BuildContext<RedisMessage> for StreamContext
Source§fn build(msg: &RedisMessage) -> Self
fn build(msg: &RedisMessage) -> Self
msg.Source§impl Clone for StreamContext
impl Clone for StreamContext
Source§impl Debug for StreamContext
impl Debug for StreamContext
Source§impl Field<StreamContext> for FredPool
impl Field<StreamContext> for FredPool
Source§impl Field<StreamContext> for EntryId
impl Field<StreamContext> for EntryId
Source§impl Field<StreamContext> for Position
impl Field<StreamContext> for Position
Source§type Value<'a> = RedisGroupPosition
type Value<'a> = RedisGroupPosition
'a.Source§fn get(self, src: &StreamContext) -> RedisGroupPosition
fn get(self, src: &StreamContext) -> RedisGroupPosition
src.Source§impl Field<StreamContext> for SeekHandle
impl Field<StreamContext> for SeekHandle
Source§type Value<'a> = &'a RedisGroupSeeker
type Value<'a> = &'a RedisGroupSeeker
'a.Source§fn get(self, src: &StreamContext) -> &RedisGroupSeeker
fn get(self, src: &StreamContext) -> &RedisGroupSeeker
src.Source§impl Field<StreamContext> for ConsumerGroup
impl Field<StreamContext> for ConsumerGroup
Source§impl<State: Sync> FromContext<StreamContext, State> for Ctx<FredPool>
Ctx<keys::FredPool> beside a stream key: the handler’s context is StreamContext there.
impl<State: Sync> FromContext<StreamContext, State> for Ctx<FredPool>
Ctx<keys::FredPool> beside a stream key: the handler’s context is StreamContext there.
Source§type Rejection = !
type Rejection = !
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<'_, StreamContext, State>,
) -> impl Future<Output = Result<Self, Infallible>> + Send
fn from_context( ctx: &mut Context<'_, StreamContext, State>, ) -> impl Future<Output = Result<Self, Infallible>> + Send
Auto Trait Implementations§
impl !RefUnwindSafe for StreamContext
impl !UnwindSafe for StreamContext
impl Freeze for StreamContext
impl Send for StreamContext
impl Sync for StreamContext
impl Unpin for StreamContext
impl UnsafeUnpin for StreamContext
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
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> ⓘ
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