Module gen_stage_dispatcher

This module defines the behaviour used by producer and producer_consumer to dispatch events.

Description

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.

Note that the dispatcher state is stored separately from the state of the gen_stage itself and neither side will have direct access to the state of the other.

Data Types

keyword()

keyword() = [{atom(), any()}]

options()

options() = keyword()


Generated by EDoc