MCPcopy
hub / github.com/keploy/keploy / ReadChunk

Method ReadChunk

pkg/agent/proxy/fakeconn/fakeconn.go:208–219  ·  view source on GitHub ↗

ReadChunk returns the next Chunk from the underlying channel with timestamps intact. Bytes are returned without being copied into a caller buffer; parsers that want chunk-level timestamps (e.g. HTTP/2 frame parsers that care about per-frame arrival time) use this instead of Read. ReadChunk returns

()

Source from the content-addressed store, hash-verified

206// were drained from; callers should typically use Read XOR ReadChunk
207// on a single FakeConn to avoid mixing the two.
208func (f *FakeConn) ReadChunk() (Chunk, error) {
209 if f.closed.Load() {
210 // See Read: a chunk already delivered to f.ch (or stashed) is a
211 // recorded wire event and must survive Close. Drain what is
212 // buffered before reporting ErrClosed.
213 if c, ok := f.drainBufferedLocked(); ok {
214 return c, nil
215 }
216 return Chunk{}, ErrClosed
217 }
218 return f.readChunkLocked()
219}
220
221// drainBufferedLocked returns the next chunk that is ALREADY available
222// without blocking: first any residual bytes left in the internal stash

Callers 15

happyParserFunction · 0.80
panicParserFunction · 0.80
errorReturnParserFunction · 0.80
recordV2Method · 0.80
readRequestV2Method · 0.80
readResponseV2Method · 0.80
encodeGenericV2Function · 0.80
readStreamFunction · 0.80

Calls 3

drainBufferedLockedMethod · 0.95
readChunkLockedMethod · 0.95
LoadMethod · 0.65