pub struct ExecutionEngine<S: WorkflowState> { /* private fields */ }Expand description
执行引擎 — 拥有所有可变状态,替代 ExecutionContext。
不对节点开发者公开。节点通过 NodeContext
或 LeafContext 能力视图交互。
§三层 API
- Leaf Execution API:
build_leaf_context()— 构建只读 + emit 视图 - Composite Execution API:
clone_state(),replace_state()— 执行控制 - Runtime Control Plane:
stream,cancel,commit()— 运行时管理
Implementations§
Source§impl<S: WorkflowState> ExecutionEngine<S>
impl<S: WorkflowState> ExecutionEngine<S>
Sourcepub fn new(
state: S,
stream: Option<Arc<dyn StreamSink>>,
cancel: CancellationToken,
) -> Self
pub fn new( state: S, stream: Option<Arc<dyn StreamSink>>, cancel: CancellationToken, ) -> Self
创建新的 ExecutionEngine。
Sourcepub fn take_mutations(&mut self) -> Vec<S::Mutation>
pub fn take_mutations(&mut self) -> Vec<S::Mutation>
消费 Mutation 缓冲(Executor 调用)。
Sourcepub fn take_control(&mut self) -> (NextAction, Option<ExecutionSignal>)
pub fn take_control(&mut self) -> (NextAction, Option<ExecutionSignal>)
消费控制信号(Executor 调用)。
Sourcepub fn take_metadata(&mut self) -> NodeMetadata
pub fn take_metadata(&mut self) -> NodeMetadata
获取元数据(Executor 调用)。
Sourcepub fn take_flow_events(&mut self) -> Vec<FlowEvent>
pub fn take_flow_events(&mut self) -> Vec<FlowEvent>
消费 FlowEvent 缓冲(Executor 调用)。
Sourcepub fn stream(&self) -> Option<&dyn StreamSink>
pub fn stream(&self) -> Option<&dyn StreamSink>
获取数据面发射器引用。
Sourcepub fn cancel_token(&self) -> &CancellationToken
pub fn cancel_token(&self) -> &CancellationToken
获取取消令牌引用(Composite 节点用于 child_token)。
Sourcepub fn stream_sink(&self) -> Option<Arc<dyn StreamSink>>
pub fn stream_sink(&self) -> Option<Arc<dyn StreamSink>>
获取 stream 的 Arc 引用(Parallel 子分支 clone 用)。
Sourcepub fn into_state(self) -> S
pub fn into_state(self) -> S
取出最终状态。
Sourcepub fn take_commit_batch(&mut self) -> Vec<S::Mutation>
pub fn take_commit_batch(&mut self) -> Vec<S::Mutation>
取出 mutation batch(Executor 调用)。
这是 commit 流水线的第一段:
take_commit_batch() → TraceSink/MutationLog 消费 → apply_batch_to_state()调用方可以在此处插入 Trace 记录、MutationLog 持久化等扩展点。
Sourcepub fn apply_batch_to_state(&mut self, mutations: Vec<S::Mutation>)
pub fn apply_batch_to_state(&mut self, mutations: Vec<S::Mutation>)
将 mutation batch 应用到状态(Executor 调用)。
commit 流水线的最后一段。与 take_commit_batch() 配合使用。
Trait Implementations§
Source§impl<S: WorkflowState> ExecutionView<S> for ExecutionEngine<S>
impl<S: WorkflowState> ExecutionView<S> for ExecutionEngine<S>
Source§impl<S: WorkflowState> ExecutorState<S> for ExecutionEngine<S>
impl<S: WorkflowState> ExecutorState<S> for ExecutionEngine<S>
fn build_node_context(&mut self) -> NodeContext<'_, S>
fn build_leaf_context(&mut self) -> LeafContext<'_, S>
fn clone_state(&self) -> S
fn replace_state(&mut self, state: S)
fn apply_batch(&mut self, mutations: impl IntoIterator<Item = S::Mutation>)
fn take_control(&mut self) -> (NextAction, Option<ExecutionSignal>)
fn take_metadata(&mut self) -> NodeMetadata
fn take_flow_events(&mut self) -> Vec<FlowEvent>
Source§fn emit_flow_event(&mut self, event: FlowEvent)
fn emit_flow_event(&mut self, event: FlowEvent)
发射控制面 FlowEvent(Composite 节点如 ParallelNode 需要)。
Auto Trait Implementations§
impl<S> !RefUnwindSafe for ExecutionEngine<S>
impl<S> !UnwindSafe for ExecutionEngine<S>
impl<S> Freeze for ExecutionEngine<S>where
S: Freeze,
impl<S> Send for ExecutionEngine<S>
impl<S> Sync for ExecutionEngine<S>
impl<S> Unpin for ExecutionEngine<S>
impl<S> UnsafeUnpin for ExecutionEngine<S>where
S: UnsafeUnpin,
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