handleCancelWorkflow 处理取消工作流
(ctx *actor.Context, msg *CancelWorkflowMsg)
| 546 | |
| 547 | // handleCancelWorkflow 处理取消工作流 |
| 548 | func (c *CoordinatorActor) handleCancelWorkflow(ctx *actor.Context, msg *CancelWorkflowMsg) { |
| 549 | c.mu.Lock() |
| 550 | state, ok := c.runningWorkflows[msg.ExecutionID] |
| 551 | if ok { |
| 552 | delete(c.runningWorkflows, msg.ExecutionID) |
| 553 | } |
| 554 | c.mu.Unlock() |
| 555 | |
| 556 | if ok { |
| 557 | // 停止所有相关 Agent |
| 558 | for _, pid := range state.agents { |
| 559 | c.engine.actorSystem.Stop(pid) |
| 560 | } |
| 561 | |
| 562 | // 取消执行上下文 |
| 563 | if state.execution.cancelFunc != nil { |
| 564 | state.execution.cancelFunc() |
| 565 | } |
| 566 | } |
| 567 | } |
| 568 | |
| 569 | // handleTerminated 处理 Actor 终止通知 |
| 570 | func (c *CoordinatorActor) handleTerminated(ctx *actor.Context, msg *actor.Terminated) { |