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

Function New

pkg/asteros/asteros.go:41–70  ·  view source on GitHub ↗

New 创建 AsterOS 实例

(opts *Options)

Source from the content-addressed store, hash-verified

39
40// New 创建 AsterOS 实例
41func New(opts *Options) (*AsterOS, error) {
42 // 使用默认配置
43 if opts == nil {
44 opts = DefaultOptions()
45 }
46
47 // 验证配置
48 if err := opts.Validate(); err != nil {
49 return nil, err
50 }
51
52 // 创建上下文
53 ctx, cancel := context.WithCancel(context.Background())
54
55 // 创建 AsterOS
56 os := &AsterOS{
57 pool: opts.Pool,
58 registry: NewRegistry(),
59 interfaces: make(map[string]Interface),
60 opts: opts,
61 ctx: ctx,
62 cancel: cancel,
63 running: false,
64 }
65
66 // 初始化路由
67 os.initRouter()
68
69 return os, nil
70}
71
72// initRouter 初始化路由
73func (os *AsterOS) initRouter() {

Callers 10

mainFunction · 0.92
mainFunction · 0.92
TestNewFunction · 0.70
TestNewValidationFunction · 0.70
TestRegisterAgentFunction · 0.70
TestRegisterRoomFunction · 0.70
TestRegisterWorkflowFunction · 0.70
TestAddInterfaceFunction · 0.70
TestLifecycleFunction · 0.70
TestGettersFunction · 0.70

Calls 4

initRouterMethod · 0.95
DefaultOptionsFunction · 0.85
NewRegistryFunction · 0.70
ValidateMethod · 0.65

Tested by 8

TestNewFunction · 0.56
TestNewValidationFunction · 0.56
TestRegisterAgentFunction · 0.56
TestRegisterRoomFunction · 0.56
TestRegisterWorkflowFunction · 0.56
TestAddInterfaceFunction · 0.56
TestLifecycleFunction · 0.56
TestGettersFunction · 0.56