elixir-lang / gen_stage

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

Docs around demand modes are inconsistent #79

Closed myronmarston closed 8 years ago

myronmarston commented 8 years ago

The docs for GenStage.ask/3 say:

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.

josevalim commented 8 years ago

It is the :manual value returned by handle_subscribe. I will improve the docs.

josevalim commented 8 years ago

Fixed in master.