execution_engine/lib.rs
1//! Cloudops Execution Engine
2//!
3//! Production-ready async execution engine for system commands.
4//!
5//! ## Features
6//!
7//! - Async/non-blocking execution
8//! - Real-time output streaming
9//! - Semaphore-based concurrency control
10//! - Automatic memory cleanup
11//! - Resource limits (timeout, output size, concurrency)
12//! - Event-driven updates
13//!
14//! ## Example
15//!
16//! ```rust,no_run
17//! use execution_engine::*;
18//! use std::sync::Arc;
19//!
20//! #[tokio::main]
21//! async fn main() {
22//! let config = ExecutionConfig::default();
23//! let engine = Arc::new(ExecutionEngine::new(config).unwrap());
24//!
25//! let request = ExecutionRequest {
26//! id: Uuid::new_v4(),
27//! command: Command::Shell {
28//! command: "echo 'Hello'".to_string(),
29//! shell: "/bin/bash".to_string(),
30//! },
31//! timeout_ms: Some(5000),
32//! env: HashMap::new(),
33//! working_dir: None,
34//! metadata: ExecutionMetadata::default(),
35//! };
36//!
37//! let execution_id = engine.execute(request).await.unwrap();
38//!
39//! let result = engine.wait_for_completion(execution_id).await.unwrap();
40//!
41//! println!("Output: {}", result.stdout);
42//! }
43//! ```
44
45// Module declarations
46mod cleanup;
47mod commands;
48mod config;
49mod engine;
50mod errors;
51mod events;
52mod executor;
53mod types;
54
55// Public exports
56pub use config::*;
57pub use engine::ExecutionEngine;
58pub use errors::*;
59pub use events::*;
60pub use types::*;
61
62// Re-exports for convenience
63pub use chrono::{DateTime, Utc};
64pub use std::collections::HashMap;
65pub use std::path::PathBuf;
66pub use std::sync::Arc;
67pub use std::time::Duration;
68pub use tokio::sync::RwLock;
69pub use uuid::Uuid;
70
71// Type aliases for complex types
72/// Type alias for the execution map (shared state across threads)
73pub type ExecutionMap = Arc<RwLock<HashMap<Uuid, Arc<RwLock<types::ExecutionState>>>>>;
74
75/// Type alias for a single execution handle
76pub type ExecutionHandle = Arc<RwLock<types::ExecutionState>>;