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

Method lookupFunction

src/go/plugin/framework/functions/manager.go:759–786  ·  view source on GitHub ↗

lookupFunction returns a snapshot handler used by existing tests to verify registry snapshot semantics at lookup time.

(name string)

Source from the content-addressed store, hash-verified

757// lookupFunction returns a snapshot handler used by existing tests to verify
758// registry snapshot semantics at lookup time.
759func (m *Manager) lookupFunction(name string) (func(Function), bool) {
760 snap, ok := m.snapshotFunction(name)
761 if !ok {
762 return nil, false
763 }
764 unknownHandler := m.unknownFunctionHandler()
765
766 return func(f Function) {
767 if len(snap.prefixes) > 0 {
768 if len(f.Args) > 0 {
769 id := f.Args[0]
770 if _, handler, matched := matchPrefix(snap.prefixes, id); matched && handler != nil {
771 handler(f)
772 return
773 }
774 }
775 unknownHandler(f)
776 return
777 }
778
779 if snap.direct != nil {
780 snap.direct(f)
781 return
782 }
783
784 unknownHandler(f)
785 }, true
786}
787
788func (m *Manager) unknownFunctionHandler() func(Function) {
789 return func(f Function) {

Callers 1

Calls 4

snapshotFunctionMethod · 0.95
matchPrefixFunction · 0.85
handlerFunction · 0.85

Tested by 1