executeWorkflowAsync 异步执行工作流
(execution *WorkflowExecution, state *workflowState)
| 313 | |
| 314 | // executeWorkflowAsync 异步执行工作流 |
| 315 | func (c *CoordinatorActor) executeWorkflowAsync(execution *WorkflowExecution, state *workflowState) { |
| 316 | execution.mu.Lock() |
| 317 | execution.Status = StatusRunning |
| 318 | execution.mu.Unlock() |
| 319 | |
| 320 | // 查找开始节点 |
| 321 | startNodes := c.findStartNodes(execution.Definition) |
| 322 | if len(startNodes) == 0 { |
| 323 | state.errorCh <- errors.New("no start node found") |
| 324 | return |
| 325 | } |
| 326 | |
| 327 | // 执行节点 |
| 328 | if err := c.executeNodes(execution, state, startNodes); err != nil { |
| 329 | state.errorCh <- err |
| 330 | return |
| 331 | } |
| 332 | |
| 333 | // 构建结果 |
| 334 | result := execution.buildResult() |
| 335 | state.resultCh <- result |
| 336 | |
| 337 | // 清理 |
| 338 | c.mu.Lock() |
| 339 | delete(c.runningWorkflows, execution.ID) |
| 340 | c.mu.Unlock() |
| 341 | } |
| 342 | |
| 343 | // executeNodes 执行节点列表 |
| 344 | func (c *CoordinatorActor) executeNodes(execution *WorkflowExecution, state *workflowState, nodeIDs []string) error { |
no test coverage detected