1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//! # Graph-Based Execution for StreamWeave
//!
//! This module provides comprehensive graph-based execution capabilities for StreamWeave,
//! enabling producers, transformers, and consumers to be connected in complex graph
//! topologies for sophisticated data processing pipelines.
//!
//! ## Overview
//!
//! The graph module provides:
//!
//! - **Graph Construction**: Direct graph construction with runtime validation
//! - **Complex Topologies**: Support for fan-in, fan-out, and complex routing patterns
//! - **Node System**: Wrapper nodes for producers, transformers, and consumers
//! - **Execution Engine**: Concurrent execution of graph nodes with stream routing
//! - **Zero-Copy Support**: Efficient zero-copy data sharing for in-process execution
//! - **Distributed Execution**: Support for distributed graph execution across nodes
//! - **Serialization**: Message serialization for distributed execution
//! - **Routing**: Flexible routing strategies (round-robin, broadcast, custom)
//!
//! ## Core Components
//!
//! - **Graph**: The main graph structure for executing data processing pipelines
//! - **Nodes**: Wrapper types for producers, transformers, and consumers in graphs
//! - **Execution**: Execution engine for running graphs with concurrent node execution
//! - **Router**: Routing strategies for distributing data across multiple outputs
//! - **Channels**: Communication channels between graph nodes
//!
//! ## Universal Message Model
//!
//! **All data flowing through graphs is automatically wrapped in `Message<T>`.** This ensures
//! message IDs, metadata, and error correlation are preserved throughout the graph execution.
//!
//! ## Example
//!
//! ```rust,no_run
//! use streamweave::Graph;
//! use streamweave::nodes::arithmetic::AddNode;
//!
//! let mut graph = Graph::new("calculator".to_string());
//! graph.add_node("adder".to_string(), Box::new(AddNode::new("adder".to_string())))?;
//! graph.expose_input_port("adder", "in1", "input")?;
//! graph.expose_output_port("adder", "out", "output")?;
//! ```