pub struct RuntimeController { /* private fields */ }Expand description
Coordinates lifecycle, idempotency, command dispatch, events and audit.
Implementations§
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 the complete command dispatch transaction.
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.
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 command outcome and emits accepted events after handler execution.