pub struct ExecutionEngine { /* private fields */ }Expand description
Main execution engine
Thread-safe, async execution engine with:
- Semaphore-based concurrency limiting
- In-memory state management
- Event emission support
- Automatic cleanup (optional)
Implementations§
Source§impl ExecutionEngine
impl ExecutionEngine
Sourcepub fn new(config: ExecutionConfig) -> Result<Self>
pub fn new(config: ExecutionConfig) -> Result<Self>
Create new ExecutionEngine
Sourcepub fn with_event_handler(self, handler: Arc<dyn EventHandler>) -> Self
pub fn with_event_handler(self, handler: Arc<dyn EventHandler>) -> Self
Set event handler (builder pattern)
Sourcepub async fn execute(&self, request: ExecutionRequest) -> Result<Uuid>
pub async fn execute(&self, request: ExecutionRequest) -> Result<Uuid>
Execute a command asynchronously
Returns execution ID immediately and spawns background task. Use get_status() or get_result() to check progress.
Sourcepub async fn get_status(&self, execution_id: Uuid) -> Result<ExecutionStatus>
pub async fn get_status(&self, execution_id: Uuid) -> Result<ExecutionStatus>
Get current status of an execution
Sourcepub async fn get_result(&self, execution_id: Uuid) -> Result<ExecutionResult>
pub async fn get_result(&self, execution_id: Uuid) -> Result<ExecutionResult>
Get execution result (returns error if not complete)
Sourcepub async fn wait_for_completion(
&self,
execution_id: Uuid,
) -> Result<ExecutionResult>
pub async fn wait_for_completion( &self, execution_id: Uuid, ) -> Result<ExecutionResult>
Wait for execution to complete and return result
Sourcepub async fn list_executions(&self) -> Vec<ExecutionSummary>
pub async fn list_executions(&self) -> Vec<ExecutionSummary>
List all executions in memory
Sourcepub async fn running_count(&self) -> usize
pub async fn running_count(&self) -> usize
Get number of currently running executions
Sourcepub async fn total_count(&self) -> usize
pub async fn total_count(&self) -> usize
Get total number of executions in memory
Sourcepub fn config(&self) -> &ExecutionConfig
pub fn config(&self) -> &ExecutionConfig
Get configuration
Sourcepub fn available_permits(&self) -> usize
pub fn available_permits(&self) -> usize
Get available semaphore permits (concurrency slots)
Sourcepub async fn cleanup_old_executions(&self) -> usize
pub async fn cleanup_old_executions(&self) -> usize
Clean up old executions based on retention policy
Removes executions based on:
- Age: Older than
execution_retention_secs - Count: Exceeds
max_in_memory_executions
Returns the number of executions removed.
Sourcepub async fn remove_execution(&self, execution_id: Uuid) -> Result<()>
pub async fn remove_execution(&self, execution_id: Uuid) -> Result<()>
Remove a specific execution from memory
Returns Ok(()) if removed, or NotFound error if execution doesn’t exist.
Sourcepub fn start_cleanup_task(self: Arc<Self>)
pub fn start_cleanup_task(self: Arc<Self>)
Start automatic cleanup task
Spawns a background task that runs every 5 minutes to clean up old executions.
Only starts if enable_auto_cleanup is true in config.
This method consumes self by value and requires Arc wrapper.
Trait Implementations§
Source§impl Clone for ExecutionEngine
impl Clone for ExecutionEngine
Source§fn clone(&self) -> ExecutionEngine
fn clone(&self) -> ExecutionEngine
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more