Skip to main content

Retry

Struct Retry 

Source
pub struct Retry;
Expand description

The marker of a registration’s deferred-retry slot: .out(Retry, policy) names the publish policy a retry_after copy leaves through.

The slot is an ordinary Out position, so the chain after the call takes the steps every slot takes: .codec(..) names the position’s codec, .transform(..) composes a PublishTransform the copy travels through, and a broker’s own publisher settings reach the policy through map_publisher. The deferred copy is already serialized - it is the delivery’s own bytes with the retry count incremented - so it passes the codec by, the way a Serialized value does on any slot.

The position is filled before the call: every registration whose subscription declares AddressedCopies or NamedCopies gets a publisher from the broker’s own DefaultPublish policy, and this call replaces it. On a descriptor that declares BrokerMoves the call does not compile: the broker moves the delivery itself and there is nothing of this process’s to publish. It comes after the registration’s declaration, max_attempts and dead_letter.

Where a copy goes is the subscription’s own answer, read at startup from RedeliveryAddressed: a subscription name and a publish destination are one string on a subject or a topic, and separate resources on Google Pub/Sub. A registration over a subscription which publishes its copies here and reports no address refuses to start, naming the subscription and its descriptor, instead of publishing copies into nothing once a handler asks for a delay. The slot therefore never lets a transform name the destination, and the generated AsyncAPI document ignores the position: a copy goes to the subscription’s own address, or to the declared dead-letter destination, and neither is this position’s to name.

Brokers with native delayed redelivery do not need the position: the runtime uses their nack_after instead, and no copy is published there.

§Cancel safety

The deferred copy is at-most-once over the delay window: see HandlerOutcome::retry_after.

§Examples

use std::time::Duration;

use ruststream::memory::prelude::*;

#[subscriber("orders")]
async fn reconcile(order: &Order) -> HandlerOutcome {
    let _ = order.id;
    HandlerOutcome::retry_after(Duration::from_secs(30))
}

fn app() -> RustStream {
    RustStream::new(AppInfo::new("orders", "0.1.0")).with_broker(MemoryBroker::new(), |b| {
        b.include(reconcile).out(Retry, Publish);
    })
}

Trait Implementations§

Source§

impl Clone for Retry

Source§

fn clone(&self) -> Retry

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Retry

Source§

impl Debug for Retry

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for Retry

Source§

fn default() -> Retry

Returns the “default value” for a type. Read more
Source§

impl Eq for Retry

Source§

impl Hash for Retry

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl OutSlot for Retry

Source§

const NAME: &'static str = "Retry"

The human-readable slot name, used by diagnostics and test assertions.
Source§

type Destination = Reads

The most a transform on this slot may do to a message’s destination. Read more
Source§

fn outgoing() -> Vec<OutgoingMessageMetadata>

The slot’s publish dictionary as AsyncAPI metadata, one entry per #[publishes(..)] type. The derive fills this in; the default (a marker without a dictionary) publishes nothing declared. Called once at registration; never on the publish path.
Source§

impl PartialEq for Retry

Source§

fn eq(&self, other: &Retry) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Retry

Auto Trait Implementations§

§

impl Freeze for Retry

§

impl RefUnwindSafe for Retry

§

impl Send for Retry

§

impl Sync for Retry

§

impl Unpin for Retry

§

impl UnsafeUnpin for Retry

§

impl UnwindSafe for Retry

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compares self with key and returns true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> PublishedThrough<DefaultSlot> for T

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more