Module gen_stage_broadcast_dispatcher

Function Index

ask/3
cancel/2
dispatch/3
info/2
init/1 A dispatcher that accumulates demand from all consumers before broadcasting events to all of them.
subscribe/3

Function Details

ask/3

ask(Counter, X2, X3) -> any()

cancel/2

cancel(X1, X2) -> any()

dispatch/3

dispatch(Events, Length, X3) -> any()

info/2

info(Msg, State) -> any()

init/1

init(Opts) -> any()

A dispatcher that accumulates demand from all consumers before broadcasting events to all of them.

This dispatcher guarantees that events are dispatched to all consumers without exceeding the demand of any given consumer.

The selector option

Subscribers can specify an optional selector function in their subscription options. The function receives an event and returns a boolean; when it returns false the event is not delivered to that subscriber (the dispatcher asks the producer for the discarded events so that other subscribers can receive them).

For example, to only receive events whose key field starts with foo-:

gen_stage:sync_subscribe(Consumer, [{to, Producer}, {selector, fun(Event) -> case Event of #{key := Key} -> string:prefix(Key, "foo-") =/= nomatch; _ -> false end end}])

subscribe/3

subscribe(Opts, X2, X3) -> any()


Generated by EDoc