pub struct Attempt;Expand description
The delivery’s attempt, 1 for the first delivery: the row’s attempt as it stood before the
claim; None for a table without one.
Retry backoff is the handler’s: it reads the attempt and answers with
HandlerOutcome::retry_after(..).
§Examples
use std::time::Duration;
use ruststream::prelude::*;
use ruststream_sqlx::keys::Attempt;
#[subscriber(InboxQueue::<Job>::new("charges"))]
async fn charge(request: &Charge, Ctx(attempt): Ctx<Attempt>) -> HandlerOutcome {
if try_charge(request).await {
return HandlerOutcome::ack();
}
// Doubling backoff: 1s, 2s, 4s, ...
let exponent = u32::try_from(attempt.unwrap_or(1).min(16)).unwrap_or(16);
HandlerOutcome::retry_after(Duration::from_secs(1 << (exponent - 1)))
}Trait Implementations§
Source§impl ContextField for Attempt
impl ContextField for Attempt
Source§type Context = InboxContext
type Context = InboxContext
The per-delivery context type this key reads from.
Source§fn read(self, src: &InboxContext) -> Option<u64>
fn read(self, src: &InboxContext) -> Option<u64>
Reads this key’s field out of
src. Named apart from Field::get so a key
implementing both traits stays unambiguous to call.impl Copy for Attempt
impl Eq for Attempt
impl StructuralPartialEq for Attempt
Auto Trait Implementations§
impl Freeze for Attempt
impl RefUnwindSafe for Attempt
impl Send for Attempt
impl Sync for Attempt
impl Unpin for Attempt
impl UnsafeUnpin for Attempt
impl UnwindSafe for Attempt
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<K> CtxKey for Kwhere
K: ContextField,
impl<K> CtxKey for Kwhere
K: ContextField,
Source§type Value = <K as ContextField>::Value
type Value = <K as ContextField>::Value
The owned value the extractor binds.
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
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