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

Method runWorker

src/go/plugin/framework/functions/manager_worker.go:7–47  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5import "runtime/debug"
6
7func (m *Manager) runWorker() {
8 for {
9 if m.scheduler == nil {
10 return
11 }
12 req, ok := m.scheduler.next()
13 m.observeSchedulerPending()
14 if !ok {
15 return
16 }
17 if req == nil || req.fn == nil || req.handler == nil {
18 continue
19 }
20 // Safe to skip: cancel/finalization path calls tryFinalize(), which in turn
21 // advances per-key lanes via scheduler.complete().
22 if req.ctx != nil && req.ctx.Err() != nil {
23 continue
24 }
25 if !m.startInvocation(req.fn.UID) {
26 continue
27 }
28
29 panicked := false
30 func() {
31 defer func() {
32 if v := recover(); v != nil {
33 m.Errorf("function handler panic (uid=%s): %v\n%s", req.fn.UID, v, string(debug.Stack()))
34 panicked = true
35 }
36 }()
37 req.handler(*req.fn)
38 }()
39
40 if panicked {
41 m.respUID(req.fn.UID, 500, "function handler panic")
42 continue
43 }
44
45 m.setAwaitingResultState(req.fn.UID, req.fn.Timeout)
46 }
47}

Callers

nothing calls this directly

Calls 7

startInvocationMethod · 0.95
respUIDMethod · 0.95
ErrMethod · 0.65
ErrorfMethod · 0.65
nextMethod · 0.45

Tested by

no test coverage detected