Skip to main content

foxtive_supervisor/runtime/
mod.rs

1//! Task runtime module for the Foxtive supervisor
2//!
3//! This module provides the core runtime functionality for supervising tasks,
4//! including task registration, dependency management, prerequisite handling,
5//! and supervision loops.
6
7// Re-export public types and functions
8pub use core::TaskRuntime;
9pub use helpers::{spawn_supervised, spawn_supervised_many};
10pub use types::{PrerequisiteFuture, SupervisionResult, TaskEntry};
11
12// Internal modules
13pub(crate) mod circuit_breaker;
14mod core;
15mod helpers;
16mod supervision;
17mod types;
18mod validation;
19
20#[cfg(test)]
21mod tests {
22    use super::*;
23
24    #[tokio::test]
25    async fn test_basic_supervision() {
26        use crate::contracts::SupervisedTask;
27
28        struct TestTask;
29
30        #[async_trait::async_trait]
31        impl SupervisedTask for TestTask {
32            fn id(&self) -> &'static str {
33                "test"
34            }
35            async fn run(&self) -> crate::error::SupervisorResult<()> {
36                Ok(())
37            }
38        }
39
40        let handle = spawn_supervised(TestTask);
41        let result = handle.await.unwrap();
42        assert_eq!(
43            result.final_status,
44            crate::enums::SupervisionStatus::CompletedNormally
45        );
46    }
47}