findNextNodes 查找下一批节点
(execution *WorkflowExecution, currentNodes []string)
| 735 | |
| 736 | // findNextNodes 查找下一批节点 |
| 737 | func (e *Engine) findNextNodes(execution *WorkflowExecution, currentNodes []string) []string { |
| 738 | var nextNodes []string |
| 739 | completed := make(map[string]bool) |
| 740 | |
| 741 | // 将当前节点标记为已完成 |
| 742 | for _, nodeID := range currentNodes { |
| 743 | completed[nodeID] = true |
| 744 | execution.CompletedNodes[nodeID] = true |
| 745 | } |
| 746 | |
| 747 | // 查找所有指向已完成节点的边 |
| 748 | for _, edge := range execution.Definition.Edges { |
| 749 | if completed[edge.From] { |
| 750 | // 检查所有前置节点是否都已完成 |
| 751 | if e.canExecuteNode(execution, edge.To, edge.Condition) { |
| 752 | nextNodes = append(nextNodes, edge.To) |
| 753 | } |
| 754 | } |
| 755 | } |
| 756 | |
| 757 | return nextNodes |
| 758 | } |
| 759 | |
| 760 | // canExecuteNode 检查节点是否可以执行 |
| 761 | func (e *Engine) canExecuteNode(execution *WorkflowExecution, nodeID string, condition string) bool { |
no test coverage detected