Skip to main content

RetryPermit

Struct RetryPermit 

Source
pub struct RetryPermit<'controller, 'request, 'subject> { /* private fields */ }
Expand description

Non-cloneable authorization for one exact prepared replay.

The permit exclusively borrows controller monotonic state until it is consumed. Safe code therefore cannot retain two permits from one owner. Execution is performed by the permit and never returns a reusable request.

use cloud_sdk::retry::RetryPermit;

fn duplicate(permit: RetryPermit<'_, '_, '_>) {
    let _second = permit.clone();
}
use cloud_sdk::retry::{
    MonotonicDuration, MonotonicInstant, RetryController, RetryEvent,
    RetrySubject,
};
use cloud_sdk::transport::DeliveryPhase;

fn fan_out<'initial, 'binding, 'replay, 'subject>(
    controller: &mut RetryController<'initial, 'binding>,
    replay: RetrySubject<'replay, 'subject>,
) {
    let first = controller.decide_retry(
        RetryEvent::Transport(DeliveryPhase::NotSent),
        replay,
        MonotonicDuration::new(0),
        MonotonicInstant::new(1),
    );
    let _second = controller.decide_retry(
        RetryEvent::Transport(DeliveryPhase::NotSent),
        replay,
        MonotonicDuration::new(0),
        MonotonicInstant::new(1),
    );
    drop(first);
}

Implementations§

Source§

impl<'controller, 'request, 'subject> RetryPermit<'controller, 'request, 'subject>

Source

pub const fn attempt(&self) -> u16

Returns the authorized attempt number, including the initial attempt.

Source

pub const fn delay(&self) -> MonotonicDuration

Returns the exact caller-selected delay charged to retry budgets.

Source

pub fn execute_blocking<'buffer, T>( self, now: MonotonicInstant, transport: &T, response_storage: &'buffer mut [u8], response_header_storage: &'buffer mut [u8], ) -> Result<CheckedResponseGuard<'buffer>, RetryExecutionError<T::Error>>

Authorizes and executes the exact replay once on a blocking transport.

Source

pub async fn execute_async<'transport, 'buffer, T>( self, now: MonotonicInstant, transport: &'transport T, response_storage: &'buffer mut [u8], response_header_storage: &'buffer mut [u8], ) -> Result<CheckedResponseGuard<'buffer>, RetryExecutionError<T::Error>>
where T: AsyncAuthenticatedTransport + BoundTransport, 'request: 'transport, 'subject: 'transport,

Authorizes and executes the exact replay once without owning an executor.

Source

pub async fn execute_local_async<'transport, 'buffer, T>( self, now: MonotonicInstant, transport: &'transport T, response_storage: &'buffer mut [u8], response_header_storage: &'buffer mut [u8], ) -> Result<CheckedResponseGuard<'buffer>, RetryExecutionError<T::Error>>
where T: LocalAsyncAuthenticatedTransport + BoundTransport, 'request: 'transport, 'subject: 'transport,

Authorizes and executes the exact replay once on a local async transport without owning an executor.

Trait Implementations§

Source§

impl Debug for RetryPermit<'_, '_, '_>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'controller, 'request, 'subject> !UnwindSafe for RetryPermit<'controller, 'request, 'subject>

§

impl<'controller, 'request, 'subject> Freeze for RetryPermit<'controller, 'request, 'subject>

§

impl<'controller, 'request, 'subject> RefUnwindSafe for RetryPermit<'controller, 'request, 'subject>

§

impl<'controller, 'request, 'subject> Send for RetryPermit<'controller, 'request, 'subject>

§

impl<'controller, 'request, 'subject> Sync for RetryPermit<'controller, 'request, 'subject>

§

impl<'controller, 'request, 'subject> Unpin for RetryPermit<'controller, 'request, 'subject>

§

impl<'controller, 'request, 'subject> UnsafeUnpin for RetryPermit<'controller, 'request, 'subject>

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.