Skip to content

Commit 8770ee7

Browse files
silviurosujosevalim
authored andcommitted
Add more comments in the docs about the :restart options for a children of a ConsumerSupervisor. (#232)
1 parent 5532e12 commit 8770ee7

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/consumer_supervisor.ex

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ defmodule ConsumerSupervisor do
2424
to a producer named `Producer` and starts a new process for each event
2525
received from the producer. Each new process will be started by calling
2626
`Printer.start_link/1`, which simply starts a task that will print the
27-
incoming event to the terminal.
27+
incoming event to the terminal.
2828
2929
defmodule Consumer do
3030
use ConsumerSupervisor
@@ -34,7 +34,10 @@ defmodule ConsumerSupervisor do
3434
end
3535
3636
def init(_arg) do
37-
children = [%{id: Printer, start: {Printer, :start_link, []}}]
37+
# Note: By default the restart for a child is set to :permanent
38+
# which is not supported in ConsumerSupervisor. You need to explicitly
39+
# set the :restart option either to :temporary or :transient.
40+
children = [%{id: Printer, start: {Printer, :start_link, []}, restart: :transient}]
3841
opts = [strategy: :one_for_one, subscribe_to: [{Producer, max_demand: 50}]]
3942
ConsumerSupervisor.init(children, opts)
4043
end

0 commit comments

Comments
 (0)