MCPcopy
hub / github.com/grpc/grpc-go / Read

Method Read

internal/transport/transport.go:161–180  ·  view source on GitHub ↗

Read reads the next n bytes from last. If last is drained, it tries to read additional data from recv. It blocks if there no additional data available in recv. If Read returns any non-nil error, it will continue to return that error.

(n int)

Source from the content-addressed store, hash-verified

159// recv. If Read returns any non-nil error, it will continue to return that
160// error.
161func (r *recvBufferReader) Read(n int) (buf mem.Buffer, err error) {
162 if r.err != nil {
163 return nil, r.err
164 }
165 if r.last != nil {
166 buf = r.last
167 if r.last.Len() > n {
168 buf, r.last = mem.SplitUnsafe(buf, n)
169 } else {
170 r.last = nil
171 }
172 return buf, nil
173 }
174 if r.clientStream != nil {
175 buf, r.err = r.readClient(n)
176 } else {
177 buf, r.err = r.read(n)
178 }
179 return buf, r.err
180}
181
182func (r *recvBufferReader) readMessageHeader(header []byte) (n int, err error) {
183 select {

Callers

nothing calls this directly

Calls 4

readClientMethod · 0.95
readMethod · 0.95
SplitUnsafeFunction · 0.92
LenMethod · 0.65

Tested by

no test coverage detected