MCPcopy Index your code
hub / github.com/netdata/netdata / Register

Method Register

src/go/plugin/framework/functions/ext.go:7–30  ·  view source on GitHub ↗
(name string, fn func(Function))

Source from the content-addressed store, hash-verified

5import "strings"
6
7func (m *Manager) Register(name string, fn func(Function)) {
8 if fn == nil {
9 m.Warningf("not registering '%s': nil function", name)
10 return
11 }
12
13 m.mux.Lock()
14 defer m.mux.Unlock()
15
16 fs, ok := m.functionRegistry[name]
17 if !ok {
18 m.Debugf("registering function '%s' (direct)", name)
19 fs = &functionSet{prefixes: make(map[string]func(Function))}
20 m.functionRegistry[name] = fs
21 } else {
22 if fs.direct != nil {
23 m.Warningf("re-registering direct function '%s'", name)
24 } else {
25 m.Debugf("registering function '%s' (direct)", name)
26 }
27 }
28
29 fs.direct = fn
30}
31
32func (m *Manager) Unregister(name string) {
33 m.mux.Lock()

Callers 2

TestManager_RegisterFunction · 0.95
TestManager_RunFunction · 0.95

Calls 4

LockMethod · 0.80
UnlockMethod · 0.80
WarningfMethod · 0.65
DebugfMethod · 0.65

Tested by 2

TestManager_RegisterFunction · 0.76
TestManager_RunFunction · 0.76