rust_logic_graph/orchestrator/
mod.rs

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