Skip to content

Commit

Permalink
Introduce Task.Supervisor.option type
Browse files Browse the repository at this point in the history
  • Loading branch information
fishcakez committed Apr 21, 2017
1 parent cad986d commit 4360198
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
10 changes: 6 additions & 4 deletions lib/elixir/lib/supervisor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -256,11 +256,13 @@ defmodule Supervisor do
@typedoc "The Supervisor name"
@type name :: atom | {:global, term} | {:via, module, term}

@typedoc "Option values used by the `start*` functions"
@type option :: {:name, name} | {:strategy, Supervisor.Spec.strategy} |
{:max_restarts, non_neg_integer} |
{:max_seconds, non_neg_integer}

@typedoc "Options used by the `start*` functions"
@type options :: [name: name,
strategy: Supervisor.Spec.strategy,
max_restarts: non_neg_integer,
max_seconds: non_neg_integer]
@type options :: [option, ...]

@typedoc "The supervisor reference"
@type supervisor :: pid | name | {atom, node}
Expand Down
6 changes: 5 additions & 1 deletion lib/elixir/lib/task/supervisor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ defmodule Task.Supervisor do
`GenServer`. Read more about them in the `GenServer` docs.
"""

@typedoc "Option values used by `start_link`"
@type option :: Supervisor.option | {:restart, Supervisor.Spec.restart} |
{:shutdown, Supervisor.Spec.shutdown}

@doc """
Starts a new supervisor.
Expand All @@ -37,7 +41,7 @@ defmodule Task.Supervisor do
* `:max_restarts` and `:max_seconds` - as specified in `Supervisor.Spec.supervise/2`;
"""
@spec start_link(Supervisor.options) :: Supervisor.on_start
@spec start_link([option]) :: Supervisor.on_start
def start_link(opts \\ []) do
import Supervisor.Spec
{restart, opts} = Keyword.pop(opts, :restart, :temporary)
Expand Down

0 comments on commit 4360198

Please sign in to comment.