elixir-mint / mint

Functional HTTP client for Elixir with support for HTTP/1 and HTTP/2 🌱
Apache License 2.0
1.36k stars 106 forks source link

User's control of WINDOW_UPDATE frame #357

Closed slashmili closed 2 years ago

slashmili commented 2 years ago

I'm trying to use Mint as base library to make gRPC calls. The scenario that I have is that when the grpc service is something like this :

 message EchoRequest {
   string message = 1;
 }

 message EchoResponse {
   string message = 1;
 }
 service Echo {
   rpc ServerStreamingEcho(EchoRequest) returns (stream EchoResponse) {}
}

In this case the server could send stream of EchoResponse to the client. I was thinking one way to make sure that Server is not flooding the client with data that it can not handle is if I can leverage WINDOW_UPDATE frame in the client side.

I looked into the Mint code and it seems that Mint's internally is keeping track of it.

Do you think it's possible to allow users to set WINDOW_UPDATE?

the-mikedavis commented 2 years ago

Since the window is only refilled when calling Mint.HTTP2.stream/2 on incoming data, you can exert back-pressure against the server by waiting to call Mint.HTTP2.stream/2 until the client is ready to handle more data.

slashmili commented 2 years ago

Thanks @the-mikedavis. it makes sense!