producer
and
producer_consumer
to dispatch events.
This module defines the behaviour used by producer
and
producer_consumer
to dispatch events.
When using a producer
or producer_consumer
, the dispatcher
may be configured on init as follows:
{producer, State, [{dispatcher, gen_stage_broadcoast_dispatcher}]}
Some dispatchers may require options to be given on initialization, those can be done with a tuple:
{producer, State, [{dispatcher, {gen_stage_partition_dispatcher, [{partitions, lists:seq(0, 3)}]}}]}
Stage ships with the following dispatcher implementations:
* gen_stage_demand_dispatcher
- dispatches the given batch of
events to the consumer with the biggest demand in a FIFO
ordering. This is the default dispatcher.
* gen_stage_broadcast_dispatcher
- dispatches all events to all
consumers. The demand is only sent upstream once all consumers
ask for data.
* gen_stage_partition_dispatcher
- dispatches all events to a
fixed amount of consumers that works as partitions according
to a hash function.
gen_stage
itself and neither side will have direct access
to the state of the other.
keyword() = [{atom(), any()}]
options() = keyword()
Generated by EDoc