View Source Electric.Shapes.Dispatcher (electric v0.9.5)

Dispatches transactions and relations to consumers filtered using Filter and the consumer's shape.

The essential behaviour is that the dispatcher only asks the producer for more demand once all relevant subscribers have processed the last message and asked for the next.

This behaviour is subtly different from GenStage.BroadcastDispatcher in that events that don't match the consumer's selector do not generate demand. We only wait for the consumers who received the event to ack successful processing before forwarding demand onto the producer.

This is not a generalised dispatcher, its behaviour is specialised to our requirements. Demand is always 1 -- consumers MUST only ever ask for a single message from the producer and the dispatcher MUST only ever receive 1 message from the producer to dispatch.

This can be done by subscribing with max_demand: 1 or using manual demand and calling GenStage.ask(producer, 1).