pub struct ParallelNode { /* private fields */ }Expand description
并行节点 — 同时执行多个分支,合并 StateDelta。
每个分支接收相同的 State 快照,独立产生 StateDelta。
所有分支完成后,Delta 通过 ReducerRegistry::merge_deltas() 合并到 State。
§示例
ⓘ
let parallel = ParallelNode::builder()
.branch("search", Arc::new(SearchNode::new()))
.branch("analyze", Arc::new(AnalyzeNode::new()))
.build();
graph.node("research", NodeKind::Parallel(parallel));Implementations§
Source§impl ParallelNode
impl ParallelNode
Sourcepub fn builder() -> ParallelNodeBuilder
pub fn builder() -> ParallelNodeBuilder
创建构建器。
Sourcepub fn with_label(self, label: impl Into<String>) -> Self
pub fn with_label(self, label: impl Into<String>) -> Self
设置调试标签。
Sourcepub fn branch_count(&self) -> usize
pub fn branch_count(&self) -> usize
获取分支数量。
Sourcepub fn branch_names(&self) -> Vec<&str>
pub fn branch_names(&self) -> Vec<&str>
获取分支名称列表。
Sourcepub fn branches_iter(&self) -> impl Iterator<Item = (&str, &Arc<dyn FlowNode>)>
pub fn branches_iter(&self) -> impl Iterator<Item = (&str, &Arc<dyn FlowNode>)>
迭代所有分支(名称, 节点)引用。
Sourcepub fn error_strategy(&self) -> ParallelErrorStrategy
pub fn error_strategy(&self) -> ParallelErrorStrategy
获取错误处理策略。
Sourcepub async fn execute_sequential(
&self,
state: &State,
) -> Result<NodeOutput, GraphError>
pub async fn execute_sequential( &self, state: &State, ) -> Result<NodeOutput, GraphError>
串行执行所有分支(用于阻塞模式 fallback)。
⚠️ 此方法顺序执行各分支,不发挥并行优势。
真正的并行执行由 Executor::handle_parallel() 完成。
Trait Implementations§
Source§impl Clone for ParallelNode
impl Clone for ParallelNode
Source§fn clone(&self) -> ParallelNode
fn clone(&self) -> ParallelNode
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for ParallelNode
impl !UnwindSafe for ParallelNode
impl Freeze for ParallelNode
impl Send for ParallelNode
impl Sync for ParallelNode
impl Unpin for ParallelNode
impl UnsafeUnpin for ParallelNode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more