MCPcopy
hub / github.com/netdata/netdata / lookupFunctionRoute

Method lookupFunctionRoute

src/go/plugin/framework/functions/manager.go:732–755  ·  view source on GitHub ↗
(fn Function)

Source from the content-addressed store, hash-verified

730}
731
732func (m *Manager) lookupFunctionRoute(fn Function) (handler func(Function), scheduleKey string, ok bool) {
733 snap, ok := m.snapshotFunction(fn.Name)
734 if !ok {
735 return nil, "", false
736 }
737 unknownHandler := m.unknownFunctionHandler()
738
739 if len(snap.prefixes) > 0 {
740 if len(fn.Args) > 0 {
741 id := fn.Args[0]
742 if prefix, routeHandler, matched := matchPrefix(snap.prefixes, id); matched && routeHandler != nil {
743 return routeHandler, routeScheduleKey(fn.Name, prefix), true
744 }
745 }
746
747 return unknownHandler, routeScheduleKey(fn.Name, scheduleKeyUnmatched), true
748 }
749
750 if snap.direct != nil {
751 return snap.direct, routeScheduleKey(fn.Name, ""), true
752 }
753
754 return unknownHandler, routeScheduleKey(fn.Name, scheduleKeyDirectMissing), true
755}
756
757// lookupFunction returns a snapshot handler used by existing tests to verify
758// registry snapshot semantics at lookup time.

Callers 1

dispatchInvocationMethod · 0.95

Calls 4

snapshotFunctionMethod · 0.95
matchPrefixFunction · 0.85
routeScheduleKeyFunction · 0.85

Tested by

no test coverage detected