Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion lib/grpc/client/supervisor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,16 @@ defmodule GRPC.Client.Supervisor do
use DynamicSupervisor

def start_link(opts) do
DynamicSupervisor.start_link(__MODULE__, opts, name: __MODULE__)
case DynamicSupervisor.start_link(__MODULE__, opts, name: __MODULE__) do
{:ok, _pid} = started ->
started

{:error, {:already_started, pid}} ->
{:ok, pid}

other ->
other
end
end

@impl true
Expand Down
14 changes: 14 additions & 0 deletions test/grpc/client/supervisor_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
defmodule GRPC.Client.SupervisorTest do
use ExUnit.Case, async: false

alias GRPC.Client

describe "start_link/1" do
test "allows multiple start_links" do
{:ok, second_pid} = Client.Supervisor.start_link([])
{:ok, third_pid} = Client.Supervisor.start_link([])

assert second_pid == third_pid
end
end
end
Loading