markExecutionCompleted 标记执行完成
(execution *WorkflowExecution)
| 856 | |
| 857 | // markExecutionCompleted 标记执行完成 |
| 858 | func (e *Engine) markExecutionCompleted(execution *WorkflowExecution) { |
| 859 | execution.mu.Lock() |
| 860 | defer execution.mu.Unlock() |
| 861 | |
| 862 | execution.Status = StatusCompleted |
| 863 | execution.Context.Status = StatusCompleted |
| 864 | execution.EndTime = time.Now() |
| 865 | |
| 866 | // 更新指标 |
| 867 | e.metrics.CompletedExecutions++ |
| 868 | |
| 869 | // 发布完成事件 |
| 870 | if e.eventBus != nil { |
| 871 | _ = e.eventBus.Publish(execution.Context.Context, &WorkflowEvent{ |
| 872 | Type: "workflow.completed", |
| 873 | ExecutionID: execution.ID, |
| 874 | NodeID: "", |
| 875 | Timestamp: time.Now(), |
| 876 | Data: map[string]any{ |
| 877 | "duration": execution.EndTime.Sub(execution.StartTime), |
| 878 | }, |
| 879 | }) |
| 880 | } |
| 881 | } |
| 882 | |
| 883 | // markExecutionFailed 标记执行失败 |
| 884 | func (e *Engine) markExecutionFailed(execution *WorkflowExecution, err error) { |