MCPcopy Create free account
hub / github.com/astercloud/aster / Execute

Method Execute

pkg/workflow/engine.go:189–218  ·  view source on GitHub ↗

Execute 执行工作流

(ctx context.Context, workflowID string, inputs map[string]any)

Source from the content-addressed store, hash-verified

187
188// Execute 执行工作流
189func (e *Engine) Execute(ctx context.Context, workflowID string, inputs map[string]any) (*WorkflowResult, error) {
190 // 加载工作流定义
191 def, err := e.loadWorkflowDefinition(workflowID)
192 if err != nil {
193 return nil, fmt.Errorf("failed to load workflow definition: %w", err)
194 }
195
196 // 验证输入
197 if err := e.validateInputs(def, inputs); err != nil {
198 return nil, fmt.Errorf("invalid inputs: %w", err)
199 }
200
201 // 创建执行实例
202 execution, err := e.createExecution(def, inputs)
203 if err != nil {
204 return nil, fmt.Errorf("failed to create execution: %w", err)
205 }
206
207 // 启动执行
208 go e.executeWorkflow(execution)
209
210 // 等待完成
211 select {
212 case <-execution.done:
213 return execution.buildResult(), nil
214 case <-ctx.Done():
215 e.cancelExecution(execution.ID)
216 return nil, ctx.Err()
217 }
218}
219
220// ExecuteAsync 异步执行工作流
221func (e *Engine) ExecuteAsync(ctx context.Context, workflowID string, inputs map[string]any) (string, error) {

Callers

nothing calls this directly

Calls 6

validateInputsMethod · 0.95
createExecutionMethod · 0.95
executeWorkflowMethod · 0.95
cancelExecutionMethod · 0.95
buildResultMethod · 0.80

Tested by

no test coverage detected