cancelExecution 取消执行
(executionID string)
| 917 | |
| 918 | // cancelExecution 取消执行 |
| 919 | func (e *Engine) cancelExecution(executionID string) { |
| 920 | e.executionsMu.RLock() |
| 921 | execution, exists := e.executions[executionID] |
| 922 | e.executionsMu.RUnlock() |
| 923 | |
| 924 | if !exists { |
| 925 | return |
| 926 | } |
| 927 | |
| 928 | execution.mu.Lock() |
| 929 | defer execution.mu.Unlock() |
| 930 | |
| 931 | if execution.Status != StatusRunning && execution.Status != StatusPaused { |
| 932 | return |
| 933 | } |
| 934 | |
| 935 | execution.cancelFunc() |
| 936 | execution.Status = StatusCancelled |
| 937 | execution.Context.Status = StatusCancelled |
| 938 | execution.EndTime = time.Now() |
| 939 | |
| 940 | // 发布取消事件 |
| 941 | if e.eventBus != nil { |
| 942 | _ = e.eventBus.Publish(execution.Context.Context, &WorkflowEvent{ |
| 943 | Type: "workflow.cancelled", |
| 944 | ExecutionID: executionID, |
| 945 | NodeID: "", |
| 946 | Timestamp: time.Now(), |
| 947 | }) |
| 948 | } |
| 949 | } |
| 950 | |
| 951 | // continueExecution 继续执行 |
| 952 | func (e *Engine) continueExecution(execution *WorkflowExecution) { |
no test coverage detected