Skip to content

Lack of context.Context support in Send/Receive #264

Description

@GiedriusS

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
https://github.com/bufbuild/connect-go/blob/159c8011dfbb90d26b040f8800316e24a6cdb6e3/protocol_grpc.go#L466

I think these methods should accept context.Context as the first parameter.

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions