Mountain/RunTime/Execute/mod.rs
1//! # Execute (RunTime)
2//!
3//! ## RESPONSIBILITIES
4//!
5//! Effect execution logic that bridges the declarative ActionEffect system
6//! with the Echo scheduler for high-performance task execution.
7//!
8//! Provides core execution methods through impl blocks on ApplicationRunTime:
9//! - Basic effect execution through Echo scheduler
10//! - Timeout-based execution with cancellation
11//! - Retry mechanisms with exponential backoff
12//!
13//! ## ARCHITECTURAL ROLE
14//!
15//! The execution engine in Mountain's architecture that handles the "how"
16//! of effect execution, while ActionEffect defines the "what".
17//!
18//! ## KEY COMPONENTS
19//!
20//! - **Fn**: Core effect execution functions implemented on ApplicationRunTime
21//!
22//! ## ERROR HANDLING
23//!
24//! All errors are propagated through Result<T, E> with detailed context.
25//! Effect errors are converted to CommonError when appropriate.
26//! Timeouts return timeout-specific errors.
27//! Retry failures include attempt count and last error information.
28//!
29//! ## LOGGING
30//!
31//! Uses log crate with appropriate severity levels:
32//! - `info`: Effect submission and completion
33//! - `debug`: Detailed execution steps
34//! - `warn`: Retry attempts and recoverable errors
35//! - `error`: Failed operations and timeout occurrences
36//!
37//! ## PERFORMANCE CONSIDERATIONS
38//!
39//! - Uses oneshot channels for result collection (minimal overhead)
40//! - Tasks are submitted to Echo's work-stealing scheduler
41//! - Timeout uses tokio::time::timeout for efficient cancellation
42//! - Retry with exponential backoff prevents system overload
43//!
44//! ## TODO
45//!
46//! Medium Priority:
47//! - [ ] Add effect execution metrics (count, duration, success rate)
48//! - [ ] Implement effect execution tracing and profiling
49//! - [ ] Add effect prioritization levels beyond Normal
50//! - [ ] Implement effect cancellation token propagation
51//! - [ ] Add circuit breaker pattern for failing effects
52//!
53//! Low Priority:
54//! - [ ] Implement distributed effect execution across instances
55//! - [ ] Add effect result caching for idempotent operations
56//! - [ ] Implement effect pipeline with chaining and composition
57//! - [ ] Add real-time effect monitoring dashboard
58//! - [ ] Implement adaptive timeout based on historical performance
59//! - [ ] Add effect execution limits (rate limiting)
60
61// --- Sub-modules ---
62
63/// Effect execution functions implemented on ApplicationRunTime.
64pub mod Fn;
65
66// Note: The execution functions (Run, RunWithTimeout, RunWithRetry) are now
67// implemented as methods on the ApplicationRunTime struct in Fn.rs