Skip to content

Commit ed2ebe5

Browse files
author
José Valim
committed
Remove warnings on latest Elixir
1 parent bfd9a59 commit ed2ebe5

File tree

4 files changed

+23
-23
lines changed

4 files changed

+23
-23
lines changed

lib/consumer_supervisor.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ defmodule ConsumerSupervisor do
254254
255255
"""
256256
@spec which_children(Supervisor.supervisor()) :: [
257-
{:undefined, pid | :restarting, Supervisor.Spec.worker(), Supervisor.Spec.modules()}
257+
{:undefined, pid | :restarting, :worker | :supervisor, :dynamic | [module()]}
258258
]
259259
def which_children(supervisor) do
260260
call(supervisor, :which_children)

lib/gen_stage.ex

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ defmodule GenStage do
132132
defmodule C do
133133
use GenStage
134134
135-
def start_link() do
135+
def start_link(_opts) do
136136
GenStage.start_link(C, :ok)
137137
end
138138
@@ -156,7 +156,7 @@ defmodule GenStage do
156156
157157
{:ok, a} = A.start_link(0) # starting from zero
158158
{:ok, b} = B.start_link(2) # multiply by 2
159-
{:ok, c} = C.start_link() # state does not matter
159+
{:ok, c} = C.start_link([]) # state does not matter
160160
161161
GenStage.sync_subscribe(c, to: b)
162162
GenStage.sync_subscribe(b, to: a)
@@ -258,12 +258,12 @@ defmodule GenStage do
258258
Then we can define our supervision tree like this:
259259
260260
children = [
261-
worker(A, [0]),
262-
worker(B, [2]),
263-
worker(C, []),
264-
worker(C, []),
265-
worker(C, []),
266-
worker(C, [])
261+
{A, [0]},
262+
{B, [2]},
263+
Supervisor.child_spec({C, []}, id: :c1),
264+
Supervisor.child_spec({C, []}, id: :c2),
265+
Supervisor.child_spec({C, []}, id: :c3),
266+
Supervisor.child_spec({C, []}, id: :c4)
267267
]
268268
269269
Supervisor.start_link(children, strategy: :rest_for_one)

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
defmodule GenStage.Mixfile do
22
use Mix.Project
33

4-
@version "0.14.1"
4+
@version "0.15.0"
55

66
def project do
77
[

test/consumer_supervisor_test.exs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
defmodule ConsumerSupervisorTest do
22
use ExUnit.Case, async: true
33

4-
import Supervisor.Spec
5-
64
defmodule Simple do
75
use ConsumerSupervisor
86
def init(args), do: args
@@ -116,13 +114,9 @@ defmodule ConsumerSupervisorTest do
116114

117115
describe "init/2" do
118116
test "supports old child spec" do
119-
expected = {
120-
:ok,
121-
[{Foo, {Foo, :start_link, []}, :permanent, 5000, :worker, [Foo]}],
122-
[strategy: :one_for_one]
123-
}
124-
125-
assert expected == ConsumerSupervisor.init([worker(Foo, [])], strategy: :one_for_one)
117+
spec = {Foo, {Foo, :start_link, []}, :permanent, 5000, :worker, [Foo]}
118+
expected = {:ok, [spec], strategy: :one_for_one}
119+
assert ConsumerSupervisor.init([spec], strategy: :one_for_one) == expected
126120
end
127121

128122
test "supports new child spec as tuple" do
@@ -573,12 +567,14 @@ defmodule ConsumerSupervisorTest do
573567

574568
defmodule Consumer do
575569
def start_link(opts \\ []) do
576-
children = [
577-
worker(__MODULE__, [self()], opts ++ [function: :start_child, restart: :temporary])
578-
]
570+
spec =
571+
opts
572+
|> Keyword.take([:restart, :shutdown])
573+
|> Keyword.put_new(:restart, :temporary)
574+
|> Enum.into(%{id: __MODULE__, start: {__MODULE__, :start_child, [self()]}})
579575

580576
opts = opts ++ [strategy: :one_for_one, max_restarts: 0]
581-
ConsumerSupervisor.start_link(children, opts)
577+
ConsumerSupervisor.start_link([spec], opts)
582578
end
583579

584580
def start_child(pid, :ok2) do
@@ -925,6 +921,10 @@ defmodule ConsumerSupervisorTest do
925921
end
926922
end
927923

924+
defp worker(mod, args, extra \\ []) do
925+
extra |> Enum.into(%{id: mod, start: {mod, :start_link, args}})
926+
end
927+
928928
defp assert_kill(pid, reason) do
929929
ref = Process.monitor(pid)
930930
Process.exit(pid, reason)

0 commit comments

Comments
 (0)