elixir-lang / gen_stage

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

Allow explicitly specifying :max_demand in DemandDispatcher #291

Closed lexmag closed 1 year ago

lexmag commented 1 year 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 1 year 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 1 year ago

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

josevalim commented 1 year ago

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