pub struct RuntimeController { /* private fields */ }Expand description
Coordinates lifecycle, idempotency, command dispatch, events and audit.
Implementations§
Source§impl RuntimeController
impl RuntimeController
Sourcepub fn recoverable_command_completions(&self) -> usize
pub fn recoverable_command_completions(&self) -> usize
Counts outcomes retained after a receipt failure and recoverable by retry.
This excludes executing handlers and reservations restored after restart.
Sourcepub fn recover_pending_command(
&self,
command: &CommandEnvelope,
result: CommandResult,
) -> RuntimeResult<CommandResult>
pub fn recover_pending_command( &self, command: &CommandEnvelope, result: CommandResult, ) -> RuntimeResult<CommandResult>
Finalizes a restarted pending reservation using application-owned evidence.
The trusted caller must first reconcile the external effect and provide its authoritative result. This method never invokes the handler or infers an outcome. Already resolved, missing, mismatched and active reservations fail. A receipt failure retains the supplied result for ordinary identical retry.
Sourcepub fn post_dispatch(
&self,
command: &CommandEnvelope,
dispatch_result: &RuntimeResult<CommandResult>,
) -> RuntimeResult<()>
pub fn post_dispatch( &self, command: &CommandEnvelope, dispatch_result: &RuntimeResult<CommandResult>, ) -> RuntimeResult<()>
Persists an outcome before emitting events, retaining failed completions.
Call after a successful pre_dispatch reservation. Repeating finalization
for an already resolved result does not emit its events again. At most 64
active keyed completions of 1 MiB each are retained. Oversized results leave
the reservation pending for application reconciliation. Event delivery is
still bounded process-local publication, not a transactional durable outbox.
Source§impl RuntimeController
impl RuntimeController
Sourcepub fn new(instance: RuntimeInstance) -> Self
pub fn new(instance: RuntimeInstance) -> Self
Creates a controller with process-local idempotency.
Sourcepub fn with_idempotency_store(
instance: RuntimeInstance,
idempotency: Box<dyn IdempotencyStore + Send + Sync>,
) -> Self
pub fn with_idempotency_store( instance: RuntimeInstance, idempotency: Box<dyn IdempotencyStore + Send + Sync>, ) -> Self
Creates a controller with an explicit idempotency store.
Sourcepub fn instance(&self) -> &RuntimeInstance
pub fn instance(&self) -> &RuntimeInstance
Returns the hosted immutable Runtime instance.
Sourcepub fn instance_arc(&self) -> Arc<RuntimeInstance> ⓘ
pub fn instance_arc(&self) -> Arc<RuntimeInstance> ⓘ
Returns a shared reference-counted Runtime instance.
Sourcepub fn lifecycle(&self) -> &RuntimeLifecycle
pub fn lifecycle(&self) -> &RuntimeLifecycle
Returns the process lifecycle.
Sourcepub fn idempotency_len(&self) -> usize
pub fn idempotency_len(&self) -> usize
Returns the number of active idempotency records.
Sourcepub fn idempotency_contains(&self, key: &str) -> RuntimeResult<bool>
pub fn idempotency_contains(&self, key: &str) -> RuntimeResult<bool>
Reports whether an idempotency key has an active record.
Sourcepub fn apply_lifecycle_event(
&self,
event: RuntimeLifecycleEvent,
) -> RuntimeResult<RuntimeLifecycleState>
pub fn apply_lifecycle_event( &self, event: RuntimeLifecycleEvent, ) -> RuntimeResult<RuntimeLifecycleState>
Applies one process lifecycle event.
Sourcepub fn dispatch_command(
&self,
command: &CommandEnvelope,
context: &dyn RuntimeContext,
) -> RuntimeResult<CommandResult>
pub fn dispatch_command( &self, command: &CommandEnvelope, context: &dyn RuntimeContext, ) -> RuntimeResult<CommandResult>
Runs command dispatch and completion publication.
This is not a transaction with application effects. A failed receipt write retains a bounded completion in this process; an identical retry finalizes that result without rerunning the handler. Restarted pending reservations require application-owned reconciliation.
Sourcepub fn inflight_commands(&self) -> usize
pub fn inflight_commands(&self) -> usize
Returns the number of commands currently executing or finalizing.
Sourcepub fn wait_for_inflight(&self, timeout: Duration) -> bool
pub fn wait_for_inflight(&self, timeout: Duration) -> bool
Waits up to timeout for every admitted command to finish.
Callers must request the shutdown lifecycle transition first so new commands cannot enter while the drain is in progress.
Sourcepub fn pre_dispatch(
&self,
command: &CommandEnvelope,
) -> RuntimeResult<Option<RuntimeResult<CommandResult>>>
pub fn pre_dispatch( &self, command: &CommandEnvelope, ) -> RuntimeResult<Option<RuntimeResult<CommandResult>>>
Performs lifecycle and idempotency checks before handler execution.