MCPcopy
hub / github.com/netdata/netdata / handlePayloadLine

Method handlePayloadLine

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

Source from the content-addressed store, hash-verified

113}
114
115func (p *inputParser) handlePayloadLine(line string) (inputEvent, error) {
116 if line == lineFunctionPayloadEnd {
117 p.readingPayload = false
118 p.currentFn.Payload = []byte(p.payloadBuf.String())
119 fn := p.currentFn
120 p.currentFn = nil
121 p.payloadBuf.Reset()
122 return inputEvent{kind: inputEventCall, fn: fn}, nil
123 }
124
125 if hasLinePrefix(line, lineFunctionCancel) {
126 event, err := parseCancelEvent(line)
127 if err != nil {
128 // Malformed cancel must not affect payload parser state.
129 return inputEvent{}, err
130 }
131
132 if p.currentFn != nil && event.uid == p.currentFn.UID {
133 p.resetPayloadState()
134 event.preAdmission = true
135 }
136 return event, nil
137 }
138
139 if hasLinePrefix(line, lineFunctionProgress) {
140 return parseProgressEvent(line), nil
141 }
142
143 if line == lineQuit {
144 p.resetPayloadState()
145 return inputEvent{kind: inputEventQuit}, nil
146 }
147
148 if hasLinePrefix(line, lineFunction) || strings.HasPrefix(line, lineFunction+"_") {
149 p.resetPayloadState()
150 return p.parseEvent(line)
151 }
152
153 if p.payloadBuf.Len() > 0 {
154 p.payloadBuf.WriteByte('\n')
155 }
156 p.payloadBuf.WriteString(line)
157
158 return inputEvent{}, nil
159}
160
161func (p *inputParser) resetPayloadState() {
162 p.readingPayload = false

Callers 1

parseEventMethod · 0.95

Calls 8

resetPayloadStateMethod · 0.95
parseEventMethod · 0.95
hasLinePrefixFunction · 0.85
parseCancelEventFunction · 0.85
parseProgressEventFunction · 0.85
ResetMethod · 0.65
LenMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected