pub enum MergeStrategy {
Collect,
MergeMap,
First,
Custom(Arc<dyn Fn(Vec<Value>) -> Value + Send + Sync>),
}Expand description
How to combine outputs from multiple upstream parallel paths.
The merge strategy determines how the collected outputs from all upstream branches are combined into a single value for the deferred node’s input.
§Example
use adk_graph::deferred::MergeStrategy;
// Default strategy collects all outputs into a Vec
let strategy = MergeStrategy::default();
assert!(matches!(strategy, MergeStrategy::Collect));
// MergeMap combines all output maps with last-write-wins
let strategy = MergeStrategy::MergeMap;Variants§
Collect
Collect all outputs into a Vec<Value>.
Outputs are ordered by the insertion order of source nodes (the order in which they were recorded).
MergeMap
Merge all output maps into a single map (last-write-wins on key conflict).
Each upstream output is expected to be a JSON object. Non-object outputs are skipped. When multiple outputs contain the same key, the value from the later-recorded source wins.
First
Use only the first completed output.
Returns the output from whichever upstream path completed first (i.e., was recorded first).
Custom(Arc<dyn Fn(Vec<Value>) -> Value + Send + Sync>)
Custom merge function.
Accepts a closure that takes all collected outputs and produces a single merged value.
§Example
use std::sync::Arc;
use adk_graph::deferred::MergeStrategy;
use serde_json::{json, Value};
let strategy = MergeStrategy::Custom(Arc::new(|outputs: Vec<Value>| {
json!({ "count": outputs.len() })
}));Trait Implementations§
Source§impl Clone for MergeStrategy
impl Clone for MergeStrategy
Source§fn clone(&self) -> MergeStrategy
fn clone(&self) -> MergeStrategy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more