Clean up code
This commit is contained in:
parent
e61f75d86f
commit
a17857576d
|
@ -23,11 +23,8 @@ defmodule Chronoscope.NTS do
|
|||
name = client_name(%{host: host, port: port})
|
||||
|
||||
case Registry.lookup(NTS.Registry, name) do
|
||||
[{pid, _}] ->
|
||||
GenServer.call(pid, :terminate)
|
||||
|
||||
[] ->
|
||||
{:error, :notfound}
|
||||
[{pid, _}] -> GenServer.call(pid, :terminate)
|
||||
[] -> {:error, :notfound}
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -51,9 +48,9 @@ defmodule Chronoscope.NTS do
|
|||
"#{host}:#{port}"
|
||||
end
|
||||
|
||||
defp start_client(%{host: host, port: port}, name) do
|
||||
defp start_client(server, name) do
|
||||
NTS.DynamicSupervisor
|
||||
|> DynamicSupervisor.start_child({NTS.Client, host: host, port: port, name: {:via, Registry, {NTS.Registry, name}}})
|
||||
|> DynamicSupervisor.start_child({NTS.Client, server: server, name: {:via, Registry, {NTS.Registry, name}}})
|
||||
|> then(fn {:ok, pid} -> pid end)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,8 +6,8 @@ defmodule Chronoscope.NTS.Client do
|
|||
|
||||
@interval_in_seconds 30
|
||||
|
||||
def start_link(host: host, port: port, name: name) do
|
||||
GenServer.start_link(__MODULE__, %{host: host, port: port}, name: name)
|
||||
def start_link(server: server, name: name) do
|
||||
GenServer.start_link(__MODULE__, server, name: name)
|
||||
end
|
||||
|
||||
@impl true
|
||||
|
|
Loading…
Reference in New Issue