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

Method ExecuteWithActors

pkg/workflow/actor_engine.go:100–138  ·  view source on GitHub ↗

ExecuteWithActors 使用 Actor 模型执行工作流

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

Source from the content-addressed store, hash-verified

98
99// ExecuteWithActors 使用 Actor 模型执行工作流
100func (e *ActorEngine) ExecuteWithActors(ctx context.Context, workflowID string, inputs map[string]any) (*WorkflowResult, error) {
101 // 加载工作流定义
102 def, err := e.loadWorkflowDefinition(workflowID)
103 if err != nil {
104 return nil, fmt.Errorf("failed to load workflow definition: %w", err)
105 }
106
107 // 验证输入
108 if err := e.validateInputs(def, inputs); err != nil {
109 return nil, fmt.Errorf("invalid inputs: %w", err)
110 }
111
112 // 创建执行实例
113 execution, err := e.createExecution(def, inputs)
114 if err != nil {
115 return nil, fmt.Errorf("failed to create execution: %w", err)
116 }
117
118 // 使用协调器执行
119 resultCh := make(chan *WorkflowResult, 1)
120 errCh := make(chan error, 1)
121
122 e.coordinatorPID.Tell(&ExecuteWorkflowMsg{
123 Execution: execution,
124 ResultCh: resultCh,
125 ErrorCh: errCh,
126 })
127
128 // 等待完成
129 select {
130 case result := <-resultCh:
131 return result, nil
132 case err := <-errCh:
133 return nil, err
134 case <-ctx.Done():
135 _ = e.CancelExecution(execution.ID)
136 return nil, ctx.Err()
137 }
138}
139
140// SpawnAgent 在 Actor 系统中创建 Agent
141func (e *ActorEngine) SpawnAgent(ctx context.Context, nodeID string, agentConfig *types.AgentConfig, deps *pkgagent.Dependencies) (*actor.PID, error) {

Callers

nothing calls this directly

Calls 5

validateInputsMethod · 0.80
createExecutionMethod · 0.80
TellMethod · 0.80
CancelExecutionMethod · 0.80

Tested by

no test coverage detected