pub struct FanOutFanIn { /* private fields */ }Expand description
Fan-out/fan-in orchestrator (a form of Supervisor, P2-3).
Broadcasts the same task to N child orchestrators running in parallel
(rate-limited by max_concurrency), then merges their outputs with an
aggregator once all complete. Suited to “multi-role review / committee”
scenarios: independent perspectives each compute their own, and a unified
verdict is reached at the end.
The default aggregator joins with newlines; swap it via
FanOutFanIn::with_aggregator for voting / best-of custom strategies.
Any worker failure fails the whole run (errors are not swallowed).
Implementations§
Source§impl FanOutFanIn
impl FanOutFanIn
Sourcepub fn new(
workers: Vec<Arc<dyn Orchestrator<Input = AgentTask, Output = String>>>,
) -> Self
pub fn new( workers: Vec<Arc<dyn Orchestrator<Input = AgentTask, Output = String>>>, ) -> Self
Construct from a set of homogeneous AgentTask -> String child orchestrators;
aggregation defaults to newline-joining.
Real agents (Input=String) should be wrapped with
crate::orchestration::task_adapter before being put into the worker list.
Sourcepub fn with_aggregator(
self,
aggregator: impl Fn(Vec<String>) -> String + Send + Sync + 'static,
) -> Self
pub fn with_aggregator( self, aggregator: impl Fn(Vec<String>) -> String + Send + Sync + 'static, ) -> Self
Custom aggregator function (e.g. best-of, voting, join templates).
Sourcepub fn with_max_concurrency(self, n: usize) -> Self
pub fn with_max_concurrency(self, n: usize) -> Self
Cap the number of parallel workers (at least 1).