how to set stream.Recv() timeout?
You can wait on another goroutine and cancel the stream if the timer fires.
I don't think its a good way to rely on a separate goroutine. Why not build the timeout feature in like using context ?
To be clear, the scope of context is rpc (either unary or streaming) instead of a particular message.
I'm wondering if this is that clear on the documentation. It really deserves a "Client-Server Synchronization" and "Handling errors" chapters.
absolutly, doc is not clear enough
@iamqizhao how to cancel a strem.recv() for bidi-streaming rpc at server side. I not find any stream mehtod.
@jan4984 You can cancel a stream by canceling the context used to create it.
@MakMukhi no, I mean the server side. The stream is allocated by gRPC framewok.
@jan4984 You would return from the goroutine that received the stream.
@nhooyr but how can I return if I'm blocking at recv() call
@jan4984 recv in a different goroutine.
See also #1229 (esp. this comment and below), which is about Send() deadlines but the same concepts/techniques apply.
Most helpful comment
I'm wondering if this is that clear on the documentation. It really deserves a "Client-Server Synchronization" and "Handling errors" chapters.