MCPcopy Create free account
hub / github.com/coder/coder / accumulateReadLocked

Method accumulateReadLocked

coderd/x/chatd/chatdebug/transport.go:234–252  ·  view source on GitHub ↗

accumulateReadLocked updates the buffer, byte counters, and truncation/EOF flags after a read. The caller must hold r.mu.

(data []byte, n int, err error)

Source from the content-addressed store, hash-verified

232// accumulateReadLocked updates the buffer, byte counters, and
233// truncation/EOF flags after a read. The caller must hold r.mu.
234func (r *recordingBody) accumulateReadLocked(data []byte, n int, err error) {
235 r.bytesRead += int64(n)
236 if n > 0 && !r.truncated {
237 remaining := maxRecordedResponseBodyBytes - r.buf.Len()
238 if remaining > 0 {
239 toWrite := n
240 if toWrite > remaining {
241 toWrite = remaining
242 r.truncated = true
243 }
244 _, _ = r.buf.Write(data[:toWrite])
245 } else {
246 r.truncated = true
247 }
248 }
249 if errors.Is(err, io.EOF) {
250 r.sawEOF = true
251 }
252}
253
254func (r *recordingBody) Read(p []byte) (int, error) {
255 n, err := r.inner.Read(p)

Callers 2

ReadMethod · 0.95
drainToEOFMethod · 0.95

Calls 3

WriteMethod · 0.65
LenMethod · 0.45
IsMethod · 0.45

Tested by

no test coverage detected