Skip to content

Commit

Permalink
Changing the child so only one is available
Browse files Browse the repository at this point in the history
  • Loading branch information
chargio committed Nov 20, 2024
1 parent 176f5ae commit fc6c3ff
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ defmodule Counter.Count do
end

def start_link(_opts) do
GenServer.start_link(__MODULE__, @start_value, name: @name)
with {:ok, pid} <- GenServer.start_link(__MODULE__, @start_value, name: @name) do
{:ok, pid}
else
{:error, {:already_started, pid}}-> {:ok, pid}
{:error, other} -> {:error, other}
end
end

def incr() do
Expand Down

0 comments on commit fc6c3ff

Please sign in to comment.