This is an asynchronous request typically used by consumers in :manual demand mode.
But according to GenStage.demand/2, the only valid demand modes are :forward and :accumulate:
@doc """
Sets the demand mode for a producer.
When `:forward`, the demand is always forwarded to the `handle_demand`
callback. When `:accumulate`, demand is accumulated until its mode is
set to `:forward`. This is useful as a synchronization mechanism, where
the demand is accumulated until all consumers are subscribed. Defaults
to `:forward`.
This command is asynchronous.
"""
@spec demand(stage, :forward | :accumulate) :: :ok
def demand(stage, mode) when mode in [:forward, :accumulate] do
cast(stage, {:"$demand", mode})
end
This is quite confusing -- it's not clear what is meant by :manual demand mode given that demand/2 says only :forward and :accumulate are supported demand modes.
The docs for
GenStage.ask/3
say:But according to
GenStage.demand/2
, the only valid demand modes are:forward
and:accumulate
:This is quite confusing -- it's not clear what is meant by
:manual
demand mode given thatdemand/2
says only:forward
and:accumulate
are supported demand modes.