Lack of context.Context support in Send/Receive #276
|
Is your feature request related to a problem? Please describe. I want to implement a fan-out in my service where a request would be sent to multiple nodes and then all of the responses would be streamed back to the client. I want to be able to return partial data if some Receive() has lagged for too much i.e. to not block for the whole duration/context of the stream Describe the solution you'd like https://github.com/bufbuild/connect-go/blob/159c8011dfbb90d26b040f8800316e24a6cdb6e3/protocol_grpc.go#L341 I think these methods should accept Describe alternatives you've considered The alternative is to spawn another goroutine (for example) just for implementing a timeout. It's wasteful of resources, it forbids receiving messages as fast as possible because you need to have a channel in the middle, and it introduces unnecessary complexity Additional context N/A |
Replies: 3 comments 3 replies
|
Hi @GiedriusS - this would be great! Unfortunately, even if Under the hood, all of these APIs are wrapping Clients take a |
|
Thanks for your quick reply! I was not aware of that limitation, thank you for the link. I read through it, it's understandable now. I guess we can close this 😢 or we can keep this open so that it wouldn't be forgotten? |
|
Moving to a discussion |
Hi @GiedriusS - this would be great! Unfortunately, even if
SendandReceiveaccepted a context, there's nothing useful we can do with it. 😿Under the hood, all of these APIs are wrapping
net/http.ResponseWriter.Writeandnet/http.Request.Body.Read. Neither of those methods takes a context or any other way to set a timeout. Especially since HTTP/2 supports multiple concurrent streams on each connection, there's not even much we can do with thenet.ConnAPIs. This is tracked and discussed pretty thoroughly in golang/go#16100, and it's also mentioned briefly in the Connect docs on deployment.Clients take a
context.Contextfor each RPC and set deadlines appropriately, so you can fan out at …