pub struct PoolContext { /* private fields */ }Expand description
The per-delivery context that carries the broker’s connection pool and nothing else: what a
handler taking Ctx<keys::FredPool> alone reads, on every form.
§Examples
use fred::interfaces::KeysInterface;
use ruststream::prelude::*;
use ruststream::subscriber;
use ruststream_fred::RedisList;
use ruststream_fred::context::keys;
/// Runs a job once: a delivery of a job seen before counts past one and is dropped.
#[subscriber(RedisList::new("jobs").reliable())]
async fn work(job: &Job, Ctx(pool): Ctx<keys::FredPool>) -> HandlerOutcome {
match pool.incr::<i64, _>(format!("jobs.seen:{}", job.id)).await {
Ok(1) => HandlerOutcome::ack(),
Ok(_) => HandlerOutcome::drop(),
Err(_) => HandlerOutcome::retry(),
}
}Implementations§
Trait Implementations§
Source§impl BuildContext<RedisListMessage> for PoolContext
impl BuildContext<RedisListMessage> for PoolContext
Source§fn build(msg: &RedisListMessage) -> Self
fn build(msg: &RedisListMessage) -> Self
Builds the context value by reading fields out of
msg.Source§impl BuildContext<RedisMessage> for PoolContext
impl BuildContext<RedisMessage> for PoolContext
Source§fn build(msg: &RedisMessage) -> Self
fn build(msg: &RedisMessage) -> Self
Builds the context value by reading fields out of
msg.Source§impl BuildContext<RedisPubSubMessage> for PoolContext
impl BuildContext<RedisPubSubMessage> for PoolContext
Source§fn build(msg: &RedisPubSubMessage) -> Self
fn build(msg: &RedisPubSubMessage) -> Self
Builds the context value by reading fields out of
msg.Source§impl<F: Form> BuildContext<RoundMessage<F>> for PoolContext
impl<F: Form> BuildContext<RoundMessage<F>> for PoolContext
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 PoolContext
impl Clone for PoolContext
Source§impl Debug for PoolContext
impl Debug for PoolContext
Auto Trait Implementations§
impl !RefUnwindSafe for PoolContext
impl !UnwindSafe for PoolContext
impl Freeze for PoolContext
impl Send for PoolContext
impl Sync for PoolContext
impl Unpin for PoolContext
impl UnsafeUnpin for PoolContext
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