Skip to main content

ActionHost

Trait ActionHost 

pub trait ActionHost {
    // Required methods
    fn query(
        &self,
        caller: &Caller,
        query: CatalogueQuery,
    ) -> Pending<Result<CataloguePage, ActionHostError>> ⓘ;
    fn invoke(
        &self,
        caller: &Caller,
        request: InvokeRequest,
    ) -> Pending<Result<InvocationReceipt, ActionHostError>> ⓘ;
    fn observe(
        &self,
        caller: &Caller,
        id: &InvocationId,
    ) -> Option<InvocationState>;
    fn cancel(
        &self,
        caller: &Caller,
        id: &InvocationId,
    ) -> Result<(), ActionHostError>;

    // Provided methods
    fn retire_execution(&self, caller: &Caller) { ... }
    fn next_change(
        &self,
        caller: &Caller,
        id: &InvocationId,
    ) -> Option<Pending<()>> { ... }
    fn confirm(
        &self,
        caller: &Caller,
        request: &InvokeRequest,
    ) -> Pending<Result<Confirmation, ActionHostError>> ⓘ { ... }
}
Expand description

A peer that runs actions on behalf of authenticated remote callers.

Implementations resolve authority from caller alone and must be idempotent per InvocationId: invoking an id again with the same request reports the original invocation, with a different request fails with ActionHostError::InvocationConflict. InvocationLedger implements that rule.

Required Methods§

fn query( &self, caller: &Caller, query: CatalogueQuery, ) -> Pending<Result<CataloguePage, ActionHostError>> ⓘ

One page of what caller is offered. An action the caller may not invoke is absent, not flagged.

fn invoke( &self, caller: &Caller, request: InvokeRequest, ) -> Pending<Result<InvocationReceipt, ActionHostError>> ⓘ

Admit and start one invocation, or report the one already admitted under the same id. Never blocks: the answer is the admission (an accepted receipt, an immediate outcome, or a refusal) once the host has it; completion is followed with Self::observe.

fn observe(&self, caller: &Caller, id: &InvocationId) -> Option<InvocationState>

The latest state of an invocation caller started, or None for an id this caller does not own.

fn cancel( &self, caller: &Caller, id: &InvocationId, ) -> Result<(), ActionHostError>

Ask a running invocation to stop.

§Errors

Returns ActionHostError::UnknownInvocation for an id this caller does not own, or ActionHostError::NotCancellable.

Provided Methods§

fn retire_execution(&self, caller: &Caller)

End this admitted transport run without cancelling its app jobs.

fn next_change(&self, caller: &Caller, id: &InvocationId) -> Option<Pending<()>>

Resolves the next time invocation id (owned by caller) may have changed state, so a waiter observes it again then instead of on a timer. None when this host cannot tell; the caller then observes on its own schedule.

Wakeups may be spurious: the waiter must observe again and tolerate finding nothing new. A host that answers Some must resolve it within a bounded interval even when nothing changes (the broker’s is a second), so a change it failed to signal costs latency, never a stalled waiter: a waiting answer (settle_with) checks its deadline only when woken.

fn confirm( &self, caller: &Caller, request: &InvokeRequest, ) -> Pending<Result<Confirmation, ActionHostError>> ⓘ

Ask the person caller acts for to confirm request on their own device, as the host shows it to them. The answer is a Confirmation::Witnessed that caller invokes request again with; a caller never confirms by its own word. A host with nobody to ask answers ActionHostError::ConfirmationRequired.

Implementations on Foreign Types§

§

impl<H> ActionHost for Arc<H>
where H: ActionHost + ?Sized,

A shared host is the host: what lets one be handed to serve, which keeps a handle for answers that wait.

§

fn retire_execution(&self, caller: &Caller)

§

fn query( &self, caller: &Caller, query: CatalogueQuery, ) -> Pending<Result<CataloguePage, ActionHostError>> ⓘ

§

fn invoke( &self, caller: &Caller, request: InvokeRequest, ) -> Pending<Result<InvocationReceipt, ActionHostError>> ⓘ

§

fn observe(&self, caller: &Caller, id: &InvocationId) -> Option<InvocationState>

§

fn next_change(&self, caller: &Caller, id: &InvocationId) -> Option<Pending<()>>

§

fn cancel( &self, caller: &Caller, id: &InvocationId, ) -> Result<(), ActionHostError>

§

fn confirm( &self, caller: &Caller, request: &InvokeRequest, ) -> Pending<Result<Confirmation, ActionHostError>> ⓘ

Implementors§