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>
impl<T> InvocationLog<T>
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
A log remembering at most capacity invocations (at least one).
Sourcepub fn admit(
&mut self,
caller: &Caller,
request: &InvokeRequest,
start: impl FnOnce() -> Result<T, ActionCallError>,
) -> Result<(&T, Admission), ActionCallError>
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.
Sourcepub fn reserve(
&mut self,
caller: &Caller,
request: &InvokeRequest,
) -> Result<Reservation, ActionCallError>
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.
Sourcepub fn readmit(
&mut self,
caller: &Caller,
request: &InvokeRequest,
waits: impl FnOnce(Option<&T>) -> bool,
) -> bool
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.
Sourcepub fn complete(&mut self, id: &InvocationId, handle: T)
pub fn complete(&mut self, id: &InvocationId, handle: T)
Record the provider’s handle for a reserved invocation.
Sourcepub fn abandon(&mut self, id: &InvocationId)
pub fn abandon(&mut self, id: &InvocationId)
Release a reservation whose start failed: nothing ran, so the id may be admitted later.
Sourcepub fn request_of(&self, id: &InvocationId) -> Option<&InvokeRequest>
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.
Sourcepub fn get(&self, caller: &Caller, id: &InvocationId) -> Option<&T>
pub fn get(&self, caller: &Caller, id: &InvocationId) -> Option<&T>
The handle for an invocation caller admitted, or the caller it continues
(Caller::continues).
Trait Implementations§
Auto Trait Implementations§
impl<T> Forget for InvocationLog<T>
impl<T> Freeze for InvocationLog<T>
impl<T> Move for InvocationLog<T>
impl<T> RefUnwindSafe for InvocationLog<T>
impl<T> Send for InvocationLog<T>
impl<T> Sync for InvocationLog<T>
impl<T> Unpin for InvocationLog<T>
impl<T> UnsafeUnpin for InvocationLog<T>
impl<T> UnwindSafe for InvocationLog<T>
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
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> ⓘ
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> ⓘ
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