NewActorEngine 创建 Actor 化的工作流引擎
(config *EngineConfig, actorConfig *ActorEngineConfig)
| 66 | |
| 67 | // NewActorEngine 创建 Actor 化的工作流引擎 |
| 68 | func NewActorEngine(config *EngineConfig, actorConfig *ActorEngineConfig) (*ActorEngine, error) { |
| 69 | // 创建基础引擎 |
| 70 | engine, err := NewEngine(config) |
| 71 | if err != nil { |
| 72 | return nil, err |
| 73 | } |
| 74 | |
| 75 | if actorConfig == nil { |
| 76 | actorConfig = DefaultActorEngineConfig() |
| 77 | } |
| 78 | |
| 79 | // 创建 Actor 系统 |
| 80 | systemConfig := actor.DefaultSystemConfig() |
| 81 | systemConfig.MailboxSize = 10000 |
| 82 | actorSystem := actor.NewSystemWithConfig(actorConfig.SystemName, systemConfig) |
| 83 | |
| 84 | ae := &ActorEngine{ |
| 85 | Engine: engine, |
| 86 | actorSystem: actorSystem, |
| 87 | agentPIDs: make(map[string]*actor.PID), |
| 88 | actorConfig: actorConfig, |
| 89 | } |
| 90 | |
| 91 | // 创建协调器 Actor |
| 92 | coordinator := NewCoordinatorActor(ae) |
| 93 | ae.coordinatorPID = actorSystem.Spawn(coordinator, "coordinator") |
| 94 | |
| 95 | wfLog.Info(context.Background(), "actor engine created", map[string]any{"system_name": actorConfig.SystemName}) |
| 96 | return ae, nil |
| 97 | } |
| 98 | |
| 99 | // ExecuteWithActors 使用 Actor 模型执行工作流 |
| 100 | func (e *ActorEngine) ExecuteWithActors(ctx context.Context, workflowID string, inputs map[string]any) (*WorkflowResult, error) { |
nothing calls this directly
no test coverage detected