uni-flow 公开 API(中文注解) / ParallelFlow
Class: ParallelFlow
Defined in: core/control-flow/parallel-router.ts:8
并行 ControlFlow:同时调度多个 Unit,全部完成后(或按失败策略提前结束)再跑 reducer。
失败策略见 FailureStrategy。也可由 Workflow YAML 的 flow.type: parallel 映射而来。
Implements
Constructors
Constructor
new ParallelFlow(
units,reducer,failureStrategy?):ParallelFlow
Defined in: core/control-flow/parallel-router.ts:16
Parameters
units
可并行执行的 Unit 列表
reducer
全部并行 Unit 完成后执行的聚合 Unit
failureStrategy?
FailureStrategy = 'fail-fast'
失败策略,默认 'fail-fast'
Returns
ParallelFlow
Properties
type
readonlytype:"parallel"='parallel'
Defined in: core/control-flow/parallel-router.ts:9
Flow 类型名。
Implementation of
Methods
isComplete()
isComplete(
state):boolean
Defined in: core/control-flow/parallel-router.ts:75
Parameters
state
当前 SharedState(可读 aggregated)
Returns
boolean
fail-fast 已触发,或 reducer 已完成 / aggregated 为真
Implementation of
markCompleted()
markCompleted(
unitId):void
Defined in: core/control-flow/parallel-router.ts:53
由引擎在 Unit 成功结束时调用,标记并行分支完成。
Parameters
unitId
string
已完成的 Unit id
Returns
void
markFailed()
markFailed(
error,state):void
Defined in: core/control-flow/parallel-router.ts:63
由引擎在 Unit 失败时调用:把错误写入 state.errors,并按策略决定是否 fail-fast。
Parameters
error
Error
失败错误
state
当前 SharedState(会追加到键 errors)
Returns
void
next()
next(
state,engineCompleted?):WorkflowUnit[]
Defined in: core/control-flow/parallel-router.ts:33
先返回所有尚未完成的并行 Unit;都完成后返回 reducer(若尚未完成)。
Parameters
state
当前 SharedState
engineCompleted?
Set<string>
引擎侧已完成 Unit id 集合
Returns
本轮可调度的 Unit 列表(可能多个)
Implementation of
restore()
restore(
cursor):void
Defined in: core/control-flow/parallel-router.ts:95
Parameters
cursor
先前 serialize() 的结果
Returns
void
Implementation of
serialize()
serialize():
ControlFlowCursor
Defined in: core/control-flow/parallel-router.ts:81
Returns
可写入检查点的游标(含 completed / reducing / failed)