Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Channels

Channels define how values merge, not what is stored. When parallel nodes write to the same key simultaneously, the channel’s merge strategy determines the final value.

Channel TypeMerge StrategyTypical Use
LastValueLast write winsCounters, current step
BinaryOperatorAggregateCustom reducerMessage lists (append), log collection
EphemeralValueNot persisted, consumed on readOne-time intermediate values
TopicAppend to queue, drain clearsEvent queues, pending task lists
NamedBarrierValueTrack multi-source completionUsed internally by add_edge_join

Why channels?

Parallel nodes may write to the same key at the same time. Without a merge strategy, updates would conflict. Channels provide deterministic, configurable resolution.

Reducer channel example

#![allow(unused)]
fn main() {
let mut channels = HashMap::new();
channels.insert("messages".into(), Box::new(
    BinaryOperatorAggregate::new(|old, new| {
        match old {
            Value::Array(mut arr) => { arr.push(new); Ok(Value::Array(arr)) }
            _ => Ok(Value::Array(vec![old, new])),
        }
    })
) as Box<dyn AnyChannel>);
}