Struct InvocationLedger
pub struct InvocationLedger<T> { /* private fields */ }Expand description
The idempotency ledger behind ActionHost::invoke.
Maps each admitted InvocationId to the caller and request that
admitted it and to the host’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. The oldest entries are forgotten past capacity.
Implementations§
§impl<T> InvocationLedger<T>
impl<T> InvocationLedger<T>
pub fn with_capacity(capacity: usize) -> InvocationLedger<T>
pub fn with_capacity(capacity: usize) -> InvocationLedger<T>
A ledger remembering at most capacity invocations (at least one).
pub fn admit(
&mut self,
caller: &Caller,
request: &InvokeRequest,
start: impl FnOnce() -> Result<T, ActionHostError>,
) -> Result<(&T, Admission), ActionHostError>
pub fn admit( &mut self, caller: &Caller, request: &InvokeRequest, start: impl FnOnce() -> Result<T, ActionHostError>, ) -> Result<(&T, Admission), ActionHostError>
Admit request for caller, calling start only if the id is new.
§Errors
Returns ActionHostError::InvocationConflict when the id was
admitted for another caller or request, or whatever start returns.
pub fn reserve(
&mut self,
caller: &Caller,
request: &InvokeRequest,
) -> Result<Reservation, ActionHostError>
pub fn reserve( &mut self, caller: &Caller, request: &InvokeRequest, ) -> Result<Reservation, ActionHostError>
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 ActionHostError::InvocationConflict when the id belongs to
another caller or request, and ActionHostError::Unavailable while
an earlier start of the same invocation is still in flight.
pub fn complete(&mut self, id: &InvocationId, handle: T)
pub fn complete(&mut self, id: &InvocationId, handle: T)
Record the host’s handle for a reserved invocation.
pub 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.
pub 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.
pub fn get_mut(&mut self, caller: &Caller, id: &InvocationId) -> Option<&mut T>
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§
§impl<T> Default for InvocationLedger<T>
impl<T> Default for InvocationLedger<T>
§fn default() -> InvocationLedger<T>
fn default() -> InvocationLedger<T>
Auto Trait Implementations§
impl<T> Freeze for InvocationLedger<T>
impl<T> RefUnwindSafe for InvocationLedger<T>where
T: RefUnwindSafe,
impl<T> Send for InvocationLedger<T>where
T: Send,
impl<T> Sync for InvocationLedger<T>where
T: Sync,
impl<T> Unpin for InvocationLedger<T>where
T: Unpin,
impl<T> UnsafeUnpin for InvocationLedger<T>
impl<T> UnwindSafe for InvocationLedger<T>where
T: UnwindSafe,
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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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