Skip to content

Commit b709cba

Browse files
author
José Valim
committed
Properly document Task.Supervisor options
1 parent 1d919f5 commit b709cba

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/elixir/lib/task/supervisor.ex

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,23 @@ defmodule Task.Supervisor do
2525
described under the `Name Registration` section in the `GenServer` module
2626
docs;
2727
28+
* `:restart` - the restart strategy, may be `:temporary` (the default),
29+
`:transient` or `:permanent`. Check `Supervisor.Spec` for more info.
30+
Defaults to temporary as most tasks can't be effectively restarted after
31+
a crash;
32+
2833
* `:shutdown` - `:brutal_kill` if the tasks must be killed directly on shutdown
2934
or an integer indicating the timeout value, defaults to 5000 milliseconds;
35+
36+
* `:max_restarts` and `:max_seconds` - as specified in `Supervisor.Spec.supervise/2`;
37+
3038
"""
3139
@spec start_link(Supervisor.options) :: Supervisor.on_start
3240
def start_link(opts \\ []) do
3341
import Supervisor.Spec
42+
{restart, opts} = Keyword.pop(opts, :restart, :temporary)
3443
{shutdown, opts} = Keyword.pop(opts, :shutdown, 5000)
35-
children = [worker(Task.Supervised, [], restart: :temporary, shutdown: shutdown)]
44+
children = [worker(Task.Supervised, [], restart: restart, shutdown: shutdown)]
3645
Supervisor.start_link(children, [strategy: :simple_one_for_one] ++ opts)
3746
end
3847

0 commit comments

Comments
 (0)