Grpc-go: Does closing a stream's context flush the stream data

Created on 10 Jul 2018  路  1Comment  路  Source: grpc/grpc-go

Looking at https://godoc.org/google.golang.org/grpc#ClientConn.NewStream, it implies that I need to take steps to avoid a go-routine leak. However, I was wondering if cancelling a context (option 2), would also force the buffered messages to be flushed.

Question

>All comments

No, canceling the context kills the stream ASAP, resulting in the loss of buffered messages. The only way to ensure delivery of messages is to finish the RPC completely (call RecvMsg until it returns a non-nil error) or build it into your protocol (i.e. the server sends ack responses to individual request messages).

Was this page helpful?
0 / 5 - 0 ratings