From 43595127af4fe7b9bd7f5668293a4a4108df4242 Mon Sep 17 00:00:00 2001 From: Isaac Yonemoto Date: Mon, 30 Oct 2023 14:46:12 -0500 Subject: [PATCH 1/2] documentation improvements --- lib/gen_stage/dispatcher.ex | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/gen_stage/dispatcher.ex b/lib/gen_stage/dispatcher.ex index 856e820..e509c7a 100644 --- a/lib/gen_stage/dispatcher.ex +++ b/lib/gen_stage/dispatcher.ex @@ -27,6 +27,12 @@ defmodule GenStage.Dispatcher do fixed amount of consumers that works as partitions according to a hash function. + > ### Dispatcher State {: .info } + > + > Note that the Dispatcher state is stored separately from the state of the + > `GenStage` itself and neither side will have direct access to the state of + > the other. + """ @typedoc "Options used by `init/1`" @@ -84,11 +90,13 @@ defmodule GenStage.Dispatcher do exists, meaning they must be returned as left_over events until another consumer subscribes. - It is guaranteed the reference given in `from` points to a - reference previously given in subscribe. It is also recommended - for events to be sent with `Process.send/3` and the `[:noconnect]` - option as the consumers are all monitored by the producer. For - example: + This callback is responsible for sending events to consumer + stages. In order to do so, you must store a `from` value from a + previous `ask/3` callback. + + It is recommended for these events to be sent with `Process.send/3` + and the `[:noconnect]` option as the consumers are all monitored + by the producer. For example: Process.send(consumer, {:"$gen_consumer", {self(), consumer_ref}, events}, [:noconnect]) From 81cfcbdc2698e1054a0ee391195f100940bd014d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Mon, 30 Oct 2023 20:49:25 +0100 Subject: [PATCH 2/2] Apply suggestions from code review --- lib/gen_stage/dispatcher.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/gen_stage/dispatcher.ex b/lib/gen_stage/dispatcher.ex index e509c7a..ea12e70 100644 --- a/lib/gen_stage/dispatcher.ex +++ b/lib/gen_stage/dispatcher.ex @@ -91,7 +91,7 @@ defmodule GenStage.Dispatcher do another consumer subscribes. This callback is responsible for sending events to consumer - stages. In order to do so, you must store a `from` value from a + stages. In order to do so, you must store a `from` value from a previous `ask/3` callback. It is recommended for these events to be sent with `Process.send/3`