MCPcopy
hub / github.com/apache/devlake / scanErrorPipe

Function scanErrorPipe

backend/core/utils/ipc.go:255–272  ·  view source on GitHub ↗
(pipe io.ReadCloser, onReceive func([]byte), outboundChannel chan<- *ProcessResponse)

Source from the content-addressed store, hash-verified

253}
254
255func scanErrorPipe(pipe io.ReadCloser, onReceive func([]byte), outboundChannel chan<- *ProcessResponse) (func(), *strings.Builder) {
256 remoteErrorMsg := &strings.Builder{}
257 return func() {
258 scanner := bufio.NewScanner(pipe)
259 scanner.Split(bufio.ScanLines)
260 for scanner.Scan() {
261 src := scanner.Bytes()
262 data := make([]byte, len(src))
263 copy(data, src)
264 if onReceive != nil {
265 onReceive(data)
266 }
267 outboundChannel <- &ProcessResponse{stderr: data}
268 _, _ = remoteErrorMsg.Write(src)
269 _, _ = remoteErrorMsg.WriteString("\n")
270 }
271 }, remoteErrorMsg
272}
273
274// CreateCmd wraps the args in "sh -c" for shell-level execution
275func CreateCmd(args ...string) *exec.Cmd {

Callers 1

StreamProcessFunction · 0.85

Calls 2

ScanMethod · 0.65
WriteMethod · 0.45

Tested by

no test coverage detected