MCPcopy
hub / github.com/netdata/netdata / Load

Method Load

src/go/plugin/framework/chartengine/engine.go:51–85  ·  view source on GitHub ↗

Load compiles and publishes a new immutable program revision.

(spec *charttpl.Spec, revision uint64)

Source from the content-addressed store, hash-verified

49
50// Load compiles and publishes a new immutable program revision.
51func (e *Engine) Load(spec *charttpl.Spec, revision uint64) error {
52 if e == nil {
53 return fmt.Errorf("chartengine: nil engine")
54 }
55
56 compiled, err := Compile(spec, revision)
57 if err != nil {
58 e.logWarningf("chartengine load failed revision=%d: %v", revision, err)
59 return err
60 }
61
62 e.mu.RLock()
63 cfg := e.state.cfg
64 e.mu.RUnlock()
65
66 autogenPolicy, selectorPolicy, err := resolveEffectivePolicy(cfg, spec.Engine)
67 if err != nil {
68 e.logWarningf("chartengine load failed revision=%d: %v", revision, err)
69 return err
70 }
71
72 e.mu.Lock()
73 e.state.cfg.autogen = autogenPolicy
74 e.state.cfg.selector = selectorPolicy
75 e.state.program = compiled
76 e.state.matchIndex = buildMatchIndex(compiled.Charts())
77 // Template revision change resets routing/materialization internals.
78 e.state.routeCache = newRouteCache()
79 e.state.materialized = newMaterializedState()
80 e.state.engineEpoch++
81 e.state.outstanding = 0
82 e.mu.Unlock()
83 e.logInfof("chartengine program loaded revision=%d charts=%d metrics=%d", revision, len(compiled.Charts()), len(compiled.MetricNames()))
84 return nil
85}
86
87// LoadYAML decodes chart-template YAML, compiles it, and publishes the program.
88func (e *Engine) LoadYAML(data []byte, revision uint64) error {

Callers 1

LoadYAMLMethod · 0.95

Calls 12

logWarningfMethod · 0.95
logInfofMethod · 0.95
resolveEffectivePolicyFunction · 0.85
buildMatchIndexFunction · 0.85
newRouteCacheFunction · 0.85
newMaterializedStateFunction · 0.85
LockMethod · 0.80
UnlockMethod · 0.80
MetricNamesMethod · 0.80
CompileFunction · 0.70
ErrorfMethod · 0.65
ChartsMethod · 0.65

Tested by

no test coverage detected