markExecutionFailed 标记执行失败
(execution *WorkflowExecution, err error)
| 882 | |
| 883 | // markExecutionFailed 标记执行失败 |
| 884 | func (e *Engine) markExecutionFailed(execution *WorkflowExecution, err error) { |
| 885 | execution.mu.Lock() |
| 886 | defer execution.mu.Unlock() |
| 887 | |
| 888 | execution.Status = StatusFailed |
| 889 | execution.Context.Status = StatusFailed |
| 890 | execution.EndTime = time.Now() |
| 891 | |
| 892 | // 记录错误 |
| 893 | execution.Errors = append(execution.Errors, WorkflowError{ |
| 894 | NodeID: "", |
| 895 | NodeName: "", |
| 896 | Error: err.Error(), |
| 897 | Timestamp: time.Now(), |
| 898 | Retryable: false, |
| 899 | }) |
| 900 | |
| 901 | // 更新指标 |
| 902 | e.metrics.FailedExecutions++ |
| 903 | |
| 904 | // 发布失败事件 |
| 905 | if e.eventBus != nil { |
| 906 | _ = e.eventBus.Publish(execution.Context.Context, &WorkflowEvent{ |
| 907 | Type: "workflow.failed", |
| 908 | ExecutionID: execution.ID, |
| 909 | NodeID: "", |
| 910 | Timestamp: time.Now(), |
| 911 | Data: map[string]any{ |
| 912 | "error": err.Error(), |
| 913 | }, |
| 914 | }) |
| 915 | } |
| 916 | } |
| 917 | |
| 918 | // cancelExecution 取消执行 |
| 919 | func (e *Engine) cancelExecution(executionID string) { |
no test coverage detected