| 1026 | } |
| 1027 | |
| 1028 | func encodeFrame(req WorkerRequest) ([]byte, error) { |
| 1029 | body, err := json.Marshal(req) |
| 1030 | if err != nil { |
| 1031 | return nil, fmt.Errorf("materialize: encode request: %w", err) |
| 1032 | } |
| 1033 | if len(body) > MaxFrameBytes { |
| 1034 | return nil, fmt.Errorf("%w: %d bytes", ErrJobTooLarge, len(body)) |
| 1035 | } |
| 1036 | out := make([]byte, 4, 4+len(body)) |
| 1037 | binary.BigEndian.PutUint32(out, uint32(len(body))) |
| 1038 | return append(out, body...), nil |
| 1039 | } |
| 1040 | |
| 1041 | // --------------------------------------------------------------------------- |
| 1042 | // the child's stderr |