pub struct ExecutionEngine { /* private fields */ }Expand description
The execution engine of one process.
One per process, held by crate::capability::Context, so that the command line, an
MCP session and every HTTP worker see the same executions.
Implementations§
Source§impl ExecutionEngine
impl ExecutionEngine
Sourcepub fn store(&self) -> &Arc<ExecutionStore> ⓘ
pub fn store(&self) -> &Arc<ExecutionStore> ⓘ
The store, for the capabilities that read it.
Sourcepub fn submit(
&self,
ctx: &Context,
capability: &str,
input: Value,
actor: Actor,
) -> Result<Execution, SubmitError>
pub fn submit( &self, ctx: &Context, capability: &str, input: Value, actor: Actor, ) -> Result<Execution, SubmitError>
Accept a capability call as an execution and answer with its first snapshot.
Fast on purpose: the input is checked, the record is created, the work is queued and this returns. Nothing waits for the handler.
The answer is the execution as accepted — queued, sequence 2, the execution.queued
event already published — and never whatever a worker has since made of it. That is
what docs/EXECUTIONS.md promises a client of executions.start, and it is not a
courtesy: reading the record again after the work became dispatchable would answer
queued, running or even succeeded depending on how the machine was loaded that
millisecond, and the same window would let a worker publish execution.started before
execution.queued, whereupon the state machine refuses the queued event and the
stream loses it. Acceptance is therefore recorded and read while the queue lock is
held, before Self::dispatch can hand the pending to anybody.
Sourcepub fn cancel(&self, id: &ExecutionId, by: &str) -> CancelOutcome
pub fn cancel(&self, id: &ExecutionId, by: &str) -> CancelOutcome
Ask an execution to stop.
Sourcepub fn shutdown(&self, grace: Duration)
pub fn shutdown(&self, grace: Duration)
Stop accepting executions, ask every one that is running to stop, and wait for the
workers, up to grace.
A handler that does not look at its cancellation flag is not killed: this process is about to end, and interrupting a read half way leaves nothing behind that matters. What the wait buys is that a client watching gets the final event.