()
| 35 | } |
| 36 | |
| 37 | func (p *parser) read() (frame, error) { |
| 38 | for { |
| 39 | version, err := p.peeker.ReadByte() |
| 40 | if err != nil { |
| 41 | return frame{}, err |
| 42 | } |
| 43 | if version == EOS { |
| 44 | // At EOS, we create a new Decoder which clears out the types slice |
| 45 | // mapping the local type IDs to the shared-context types. Any data |
| 46 | // batches concurrently being decoded by a worker will still point |
| 47 | // to the old types slice so all continues on just fine as |
| 48 | // everything gets properly mappped to the shared context |
| 49 | // under concurrent locking in the target super.Context. |
| 50 | p.types = NewDecoder(p.types.sctx) |
| 51 | continue |
| 52 | } |
| 53 | if err := CheckVersion(version); err != nil { |
| 54 | return frame{}, err |
| 55 | } |
| 56 | code, err := p.peeker.ReadByte() |
| 57 | if err != nil { |
| 58 | return frame{}, err |
| 59 | } |
| 60 | switch typ := (code >> 4) & 3; typ { |
| 61 | case TypesFrame: |
| 62 | if err := p.decodeTypes(code); err != nil { |
| 63 | return frame{}, err |
| 64 | } |
| 65 | case ValuesFrame: |
| 66 | return p.decodeValues(code) |
| 67 | case ControlFrame: |
| 68 | return frame{}, p.decodeControl(code) |
| 69 | default: |
| 70 | return frame{}, fmt.Errorf("unknown BSUP message frame type: %d", typ) |
| 71 | } |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | func (p *parser) decodeTypes(code byte) error { |
| 76 | if (code & 0x40) != 0 { |
no test coverage detected