ExecuteAsync 异步执行工作流
(ctx context.Context, workflowID string, inputs map[string]any)
| 219 | |
| 220 | // ExecuteAsync 异步执行工作流 |
| 221 | func (e *Engine) ExecuteAsync(ctx context.Context, workflowID string, inputs map[string]any) (string, error) { |
| 222 | // 加载工作流定义 |
| 223 | def, err := e.loadWorkflowDefinition(workflowID) |
| 224 | if err != nil { |
| 225 | return "", fmt.Errorf("failed to load workflow definition: %w", err) |
| 226 | } |
| 227 | |
| 228 | // 验证输入 |
| 229 | if err := e.validateInputs(def, inputs); err != nil { |
| 230 | return "", fmt.Errorf("invalid inputs: %w", err) |
| 231 | } |
| 232 | |
| 233 | // 创建执行实例 |
| 234 | execution, err := e.createExecution(def, inputs) |
| 235 | if err != nil { |
| 236 | return "", fmt.Errorf("failed to create execution: %w", err) |
| 237 | } |
| 238 | |
| 239 | // 启动执行 |
| 240 | go e.executeWorkflow(execution) |
| 241 | |
| 242 | return execution.ID, nil |
| 243 | } |
| 244 | |
| 245 | // GetExecution 获取执行状态 |
| 246 | func (e *Engine) GetExecution(executionID string) (*WorkflowExecution, error) { |
nothing calls this directly
no test coverage detected