MCPcopy
hub / github.com/yusing/godoxy / Load

Function Load

internal/config/events.go:57–94  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

55}
56
57func Load() error {
58 if HasState() {
59 panic(errors.New("config already loaded"))
60 }
61 state := NewState()
62 config.WorkingState.Store(state)
63
64 cfgWatcher = watcher.NewConfigFileWatcher(common.ConfigFileName)
65
66 initErr := state.InitFromFile(common.ConfigPath)
67 if initErr != nil {
68 // if error is critical, notify and return it without starting providers
69 if criticalErr, ok := errors.AsType[CriticalError](initErr); ok {
70 logNotifyError("init", criticalErr.err)
71 return criticalErr
72 }
73 }
74
75 // disable pool logging temporary since we already have pretty logging
76 state.Entrypoint().DisablePoolsLog(true)
77 defer func() {
78 state.Entrypoint().DisablePoolsLog(false)
79 }()
80
81 err := errors.Join(initErr, state.StartProviders())
82 if err != nil {
83 logNotifyError("init", err)
84 }
85
86 state.StartAPIServers()
87 state.StartMetrics()
88
89 SetState(state)
90
91 // flush temporary log
92 state.FlushTmpLog()
93 return nil
94}
95
96func Reload() error {
97 events.Global.Add(events.NewEvent(events.LevelInfo, "config", "reload", nil))

Callers 1

mainFunction · 0.92

Calls 13

InitFromFileMethod · 0.95
EntrypointMethod · 0.95
StartProvidersMethod · 0.95
StartAPIServersMethod · 0.95
StartMetricsMethod · 0.95
FlushTmpLogMethod · 0.95
NewConfigFileWatcherFunction · 0.92
HasStateFunction · 0.85
NewStateFunction · 0.85
logNotifyErrorFunction · 0.85
SetStateFunction · 0.85
NewMethod · 0.80

Tested by

no test coverage detected