elixir-lang / gen_stage

Producer and consumer actors with back-pressure for Elixir
http://hexdocs.pm/gen_stage
1.52k stars 192 forks source link

Allow explicitly specifying :max_demand in DemandDispatcher #291

Closed lexmag closed 2 years ago

lexmag commented 2 years ago

Currently, the maximum demand gets defined by the first ask/3. This PR resolves a case when :manual consumers can legitimately increase their demand after their first ask/3. For example, a consumer representing an HTTP/2 connection to Apple Push Notification service can only determine the actual maximum demand (MAX_CONCURRENT_STREAMS) only after processing the first request, hence, the first ask being 1.

josevalim commented 2 years ago

Thank you! I think we should add a new test however, instead of changing the one about warning. Or is the only way to test this is through warning?

lexmag commented 2 years ago

Right, that warning is the only practical use of the maximum demand value in DemandDispatcher at the moment.

josevalim commented 2 years ago

:green_heart: :blue_heart: :purple_heart: :yellow_heart: :heart: