master
go 25 lines 994 Bytes
Raw
1 // SPDX-License-Identifier: GPL-3.0-or-later
2
3 package jobmgr
4
5 import (
6 "github.com/netdata/netdata/go/plugins/plugin/framework/dyncfg"
7 )
8
9 const dyncfgShuttingDownMsg = "Job manager is shutting down."
10
11 // enqueueDyncfgFunction blocks until the function is accepted by the run loop
12 // or the manager shuts down. We deliberately do NOT honor a per-function
13 // timeout here: dropping an awaited enable/disable would wedge jobmgr's wait
14 // gate (since waitDecisionTimeout was removed). Back-pressure flows upstream:
15 // dyncfgCh full -> framework worker blocks here -> scheduler fills ->
16 // dispatchInvocation blocks -> stdin reader pauses -> netdata's pipe write
17 // blocks. This is intentional so awaited state transitions preserve ordering
18 // and eventually slow the producer instead of being dropped.
19 func (m *Manager) enqueueDyncfgFunction(fn dyncfg.Function) {
20 select {
21 case m.dyncfgCh <- fn:
22 case <-m.baseContext().Done():
23 m.dyncfgResponder.SendCodef(fn, 503, dyncfgShuttingDownMsg)
24 }
25 }