rust_logic_graph/orchestrator/
mod.rs

1use anyhow::Result;
2use tracing::info;
3
4use crate::core::{Executor, Graph};
5
6pub struct Orchestrator {
7    executor: Executor,
8}
9
10impl Orchestrator {
11    /// Create a new orchestrator with an executor
12    pub fn new(executor: Executor) -> Self {
13        Self { executor }
14    }
15
16    /// Execute the graph using the internal executor
17    pub async fn execute(&mut self, graph: &mut Graph) -> Result<()> {
18        info!("Orchestrator: Starting orchestration...");
19        self.executor.execute(graph).await?;
20        info!("Orchestrator: Orchestration completed");
21        Ok(())
22    }
23
24    /// Execute a graph using a default executor built from the graph definition
25    pub async fn execute_graph(graph: &mut Graph) -> Result<()> {
26        info!("Orchestrator: Building executor from graph definition");
27        let executor = Executor::from_graph_def(&graph.def)?;
28        let mut orchestrator = Self::new(executor);
29        orchestrator.execute(graph).await
30    }
31}
32
33impl Default for Orchestrator {
34    fn default() -> Self {
35        Self::new(Executor::default())
36    }
37}