mirror of https://github.com/grpc/grpc-go.git
grpc: Update ClientStream.CloseSend docs (#8292)
This commit is contained in:
parent
c7aec4defb
commit
c84fab05de
15
stream.go
15
stream.go
|
|
@ -101,9 +101,9 @@ type ClientStream interface {
|
|||
// It must only be called after stream.CloseAndRecv has returned, or
|
||||
// stream.Recv has returned a non-nil error (including io.EOF).
|
||||
Trailer() metadata.MD
|
||||
// CloseSend closes the send direction of the stream. It closes the stream
|
||||
// when non-nil error is met. It is also not safe to call CloseSend
|
||||
// concurrently with SendMsg.
|
||||
// CloseSend closes the send direction of the stream. This method always
|
||||
// returns a nil error. The status of the stream may be discovered using
|
||||
// RecvMsg. It is also not safe to call CloseSend concurrently with SendMsg.
|
||||
CloseSend() error
|
||||
// Context returns the context for this stream.
|
||||
//
|
||||
|
|
@ -993,7 +993,7 @@ func (cs *clientStream) RecvMsg(m any) error {
|
|||
|
||||
func (cs *clientStream) CloseSend() error {
|
||||
if cs.sentLast {
|
||||
// TODO: return an error and finish the stream instead, due to API misuse?
|
||||
// Return a nil error on repeated calls to this method.
|
||||
return nil
|
||||
}
|
||||
cs.sentLast = true
|
||||
|
|
@ -1014,7 +1014,10 @@ func (cs *clientStream) CloseSend() error {
|
|||
binlog.Log(cs.ctx, chc)
|
||||
}
|
||||
}
|
||||
// We never returned an error here for reasons.
|
||||
// We don't return an error here as we expect users to read all messages
|
||||
// from the stream and get the RPC status from RecvMsg(). Note that
|
||||
// SendMsg() must return an error when one occurs so the application
|
||||
// knows to stop sending messages, but that does not apply here.
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -1378,7 +1381,7 @@ func (as *addrConnStream) Trailer() metadata.MD {
|
|||
|
||||
func (as *addrConnStream) CloseSend() error {
|
||||
if as.sentLast {
|
||||
// TODO: return an error and finish the stream instead, due to API misuse?
|
||||
// Return a nil error on repeated calls to this method.
|
||||
return nil
|
||||
}
|
||||
as.sentLast = true
|
||||
|
|
|
|||
Loading…
Reference in New Issue