MCPcopy
hub / github.com/netdata/netdata / parseEvent

Method parseEvent

src/go/plugin/framework/functions/parser.go:79–113  ·  view source on GitHub ↗
(line string)

Source from the content-addressed store, hash-verified

77}
78
79func (p *inputParser) parseEvent(line string) (inputEvent, error) {
80 if line = strings.TrimSpace(line); line == "" {
81 return inputEvent{}, nil
82 }
83
84 if p.readingPayload {
85 return p.handlePayloadLine(line)
86 }
87
88 switch {
89 case line == lineQuit:
90 return inputEvent{kind: inputEventQuit}, nil
91 case hasLinePrefix(line, lineFunctionCancel):
92 return parseCancelEvent(line)
93 case hasLinePrefix(line, lineFunctionProgress):
94 return parseProgressEvent(line), nil
95 case strings.HasPrefix(line, lineFunction+" "):
96 fn, err := p.parseFunction(line)
97 if err != nil {
98 return inputEvent{}, err
99 }
100 return inputEvent{kind: inputEventCall, fn: fn}, nil
101 case strings.HasPrefix(line, lineFunctionPayload+" "):
102 fn, err := p.parseFunction(line)
103 if err != nil {
104 return inputEvent{}, err
105 }
106 p.readingPayload = true
107 p.currentFn = fn
108 p.payloadBuf.Reset()
109 return inputEvent{}, nil
110 default:
111 return inputEvent{}, errors.New("unexpected line format")
112 }
113}
114
115func (p *inputParser) handlePayloadLine(line string) (inputEvent, error) {
116 if line == lineFunctionPayloadEnd {

Callers 4

parseMethod · 0.95
handlePayloadLineMethod · 0.95
runMethod · 0.80

Calls 7

handlePayloadLineMethod · 0.95
parseFunctionMethod · 0.95
hasLinePrefixFunction · 0.85
parseCancelEventFunction · 0.85
parseProgressEventFunction · 0.85
ResetMethod · 0.65
NewMethod · 0.65

Tested by 1