oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1package runner
2
3import (
4 "bufio"
5 "fmt"
6 "io"
7
8 "amadan.net/oficina/equipo/internal/runnerproto"
9)
10
11type stdoutFrames struct {
12 reader *bufio.Reader
13 document, consumed bool
14}
15
16func (r *stdoutFrames) read() ([]byte, error) {
17 if !r.document {
18 return r.reader.ReadSlice('\n')
19 }
20 if r.consumed {
21 return nil, io.EOF
22 }
23 r.consumed = true
24 raw, err := io.ReadAll(io.LimitReader(r.reader, MaxFrameBytes+1))
25 if err != nil {
26 return nil, err
27 }
28 if len(raw) > MaxFrameBytes {
29 return nil, fmt.Errorf("stdout_document_too_large: %w", runnerproto.ErrInvalid)
30 }
31 if !uniqueFrame(raw) {
32 return nil, fmt.Errorf("stdout_invalid_json: %w", runnerproto.ErrInvalid)
33 }
34 return raw, nil
35}
36