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

Method CmdRemove

src/go/plugin/framework/dyncfg/handler.go:564–588  ·  view source on GitHub ↗

CmdRemove handles the "remove" command.

(fn Function)

Source from the content-addressed store, hash-verified

562
563// CmdRemove handles the "remove" command.
564func (h *Handler[C]) CmdRemove(fn Function) {
565 key, _, ok := h.cb.ExtractKey(fn)
566 if !ok {
567 h.api.SendCodef(fn, 400, "invalid job ID format.")
568 return
569 }
570
571 entry, ok := h.exposed.LookupByKey(key)
572 if !ok {
573 h.api.SendCodef(fn, 404, "job not found.")
574 return
575 }
576
577 if entry.Cfg.SourceType() != "dyncfg" {
578 h.api.SendCodef(fn, 405, "removing jobs of type '%s' is not supported, only 'dyncfg' jobs can be removed.", entry.Cfg.SourceType())
579 return
580 }
581
582 h.seen.Remove(entry.Cfg)
583 h.exposed.Remove(entry.Cfg)
584 h.cb.Stop(entry.Cfg)
585
586 h.api.SendCodef(fn, 200, "%s", takeCommandMessage(h.cb))
587 h.NotifyJobRemove(entry.Cfg)
588}
589
590// CmdUpdate handles the "update" command.
591func (h *Handler[C]) CmdUpdate(fn Function) {

Callers 7

TestCmdRemove_NotFoundFunction · 0.80
dyncfgSeqExecMethod · 0.80
dyncfgCmdRemoveMethod · 0.80

Calls 8

NotifyJobRemoveMethod · 0.95
takeCommandMessageFunction · 0.85
SendCodefMethod · 0.80
LookupByKeyMethod · 0.80
ExtractKeyMethod · 0.65
SourceTypeMethod · 0.65
RemoveMethod · 0.65
StopMethod · 0.65

Tested by 4

TestCmdRemove_NotFoundFunction · 0.64