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

Method CreateAndSpawn

pkg/agent/actor.go:507–527  ·  view source on GitHub ↗

CreateAndSpawn 创建并在 Actor 系统中启动 Agent

(
	ctx context.Context,
	system *actor.System,
	config *types.AgentConfig,
	name string,
)

Source from the content-addressed store, hash-verified

505
506// CreateAndSpawn 创建并在 Actor 系统中启动 Agent
507func (f *AgentActorFactory) CreateAndSpawn(
508 ctx context.Context,
509 system *actor.System,
510 config *types.AgentConfig,
511 name string,
512) (*actor.PID, error) {
513 agentActor, err := f.Create(ctx, config)
514 if err != nil {
515 return nil, err
516 }
517
518 // 设置监督策略(Agent 应该在失败时重启)
519 props := &actor.Props{
520 Name: name,
521 MailboxSize: 100,
522 SupervisorStrategy: actor.NewOneForOneStrategy(3, time.Minute, actor.DefaultDecider),
523 }
524
525 pid := system.SpawnWithProps(agentActor, props)
526 return pid, nil
527}
528
529// ============== 辅助函数 ==============
530

Callers

nothing calls this directly

Calls 3

CreateMethod · 0.95
NewOneForOneStrategyFunction · 0.92
SpawnWithPropsMethod · 0.45

Tested by

no test coverage detected