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

Method CloseSend

stream.go:1039–1067  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1037}
1038
1039func (cs *clientStream) CloseSend() error {
1040 if cs.sentLast {
1041 // Return a nil error on repeated calls to this method.
1042 return nil
1043 }
1044 cs.sentLast = true
1045 op := func(a *csAttempt) error {
1046 a.transportStream.Write(nil, nil, &transport.WriteOptions{Last: true})
1047 // Always return nil; io.EOF is the only error that might make sense
1048 // instead, but there is no need to signal the client to call RecvMsg
1049 // as the only use left for the stream after CloseSend is to call
1050 // RecvMsg. This also matches historical behavior.
1051 return nil
1052 }
1053 cs.withRetry(op, func() { cs.bufferForRetryLocked(0, op, nil) })
1054 if len(cs.binlogs) != 0 {
1055 chc := &binarylog.ClientHalfClose{
1056 OnClientSide: true,
1057 }
1058 for _, binlog := range cs.binlogs {
1059 binlog.Log(cs.ctx, chc)
1060 }
1061 }
1062 // We don't return an error here as we expect users to read all messages
1063 // from the stream and get the RPC status from RecvMsg(). Note that
1064 // SendMsg() must return an error when one occurs so the application
1065 // knows to stop sending messages, but that does not apply here.
1066 return nil
1067}
1068
1069func (cs *clientStream) finish(err error) {
1070 if err == io.EOF {

Callers

nothing calls this directly

Calls 4

withRetryMethod · 0.95
bufferForRetryLockedMethod · 0.95
WriteMethod · 0.65
LogMethod · 0.65

Tested by

no test coverage detected