obmarg / graphql-ws-client

A GraphQL over Websockets implementation for Rust
Apache License 2.0
39 stars 15 forks source link

Unbounded buffer #102

Closed carlocorradini closed 2 months ago

carlocorradini commented 3 months ago

I've seen that the channel is always bounded (default to 5). What do you think if we also support unbounded channel (Option<usize>). Of course we should rethink on how to wrap the Sender and Receiver but I think this should be a nice feature.

obmarg commented 3 months ago

Did you have a specific use case in mind for an unbounded channel? My assumption when writing this was that you'd pretty much always want a bit of back-pressure if the client was struggling to keep up with the volume of messages coming through.

With an unbounded channel it seems like there's a risk of bugs (or just unexpected behaviour) in either the client or the server causing the channel to eat up all the memory available to it.