Skip to main content

InvocationLog

Struct InvocationLog 

Source
pub struct InvocationLog<T> { /* private fields */ }
Expand description

The idempotency log behind ActionProvider::invoke.

Maps each admitted InvocationId to the caller and request that admitted it and to the provider’s own handle for the running job. A retry with the same caller and request returns the existing handle without starting anything; any other reuse of the id is a conflict. Only admitted invocations are remembered — a refused one ran nothing, so retrying it may be admitted later. At capacity, the oldest entry whose admission completed is forgotten. In-flight reservations are never evicted.

Implementations§

Source§

impl<T> InvocationLog<T>

Source

pub fn with_capacity(capacity: usize) -> Self

A log remembering at most capacity invocations (at least one).

Source

pub fn admit( &mut self, caller: &Caller, request: &InvokeRequest, start: impl FnOnce() -> Result<T, ActionCallError>, ) -> Result<(&T, Admission), ActionCallError>

Admit request for caller, calling start only if the id is new.

§Errors

Returns ActionCallError::InvocationConflict when the id was admitted for another caller or request, ActionCallError::Unavailable when all slots are reserved, or whatever start returns.

Source

pub fn reserve( &mut self, caller: &Caller, request: &InvokeRequest, ) -> Result<Reservation, ActionCallError>

First half of an admission whose start completes later (for example across an asynchronous resolution): claim the id for caller and request, then complete or abandon it.

§Errors

Returns ActionCallError::InvocationConflict when the id belongs to another caller or request, ActionCallError::Unanswered while an earlier start of the same invocation is still in flight, and ActionCallError::Unavailable while every slot is held by an in-flight reservation.

Source

pub fn readmit( &mut self, caller: &Caller, request: &InvokeRequest, waits: impl FnOnce(Option<&T>) -> bool, ) -> bool

Admit request again under its id where its person approved the asked record it waits in: the entry caller admitted for the same target and arguments, whose handle waits says is still asked, is reserved again carrying their answer, and the caller completes or abandons it as after Self::reserve. waits is handed None while the entry’s first start is still in flight. False where nothing of that waits, which a reserve then refuses as another invocation.

Source

pub fn complete(&mut self, id: &InvocationId, handle: T)

Record the provider’s handle for a reserved invocation.

Source

pub fn abandon(&mut self, id: &InvocationId)

Release a reservation whose start failed: nothing ran, so the id may be admitted later.

Source

pub fn request_of(&self, id: &InvocationId) -> Option<&InvokeRequest>

The request that admitted invocation id, for the provider that keeps this log: what an app it runs the invocation in carries as the proof of a call it makes for it.

Source

pub fn get(&self, caller: &Caller, id: &InvocationId) -> Option<&T>

The handle for an invocation caller admitted, or the caller it continues (Caller::continues).

Source

pub fn admitted(&self, caller: &Caller, id: &InvocationId) -> Option<Option<&T>>

The invocation caller admitted under id, as its handle: Some(None) while its start is still in flight, None where caller admitted nothing under id.

Source

pub fn get_mut(&mut self, caller: &Caller, id: &InvocationId) -> Option<&mut T>

Mutable access to the handle for an invocation caller admitted.

Trait Implementations§

Source§

impl<T> Default for InvocationLog<T>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<T> Forget for InvocationLog<T>

§

impl<T> Freeze for InvocationLog<T>
where HashMap<InvocationId, LogEntry<T>>: Freeze,

§

impl<T> Move for InvocationLog<T>

§

impl<T> RefUnwindSafe for InvocationLog<T>
where HashMap<InvocationId, LogEntry<T>>: RefUnwindSafe,

§

impl<T> Send for InvocationLog<T>
where HashMap<InvocationId, LogEntry<T>>: Send,

§

impl<T> Sync for InvocationLog<T>
where HashMap<InvocationId, LogEntry<T>>: Sync,

§

impl<T> Unpin for InvocationLog<T>
where HashMap<InvocationId, LogEntry<T>>: Unpin,

§

impl<T> UnsafeUnpin for InvocationLog<T>
where HashMap<InvocationId, LogEntry<T>>: UnsafeUnpin,

§

impl<T> UnwindSafe for InvocationLog<T>
where HashMap<InvocationId, LogEntry<T>>: UnwindSafe,

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

Source§

type Output = T

Should always be Self
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