Clean up code

This commit is contained in:
Mike Cifelli 2024-04-14 19:17:11 -04:00
parent e61f75d86f
commit a17857576d
Signed by: mike
GPG Key ID: 6B08C6BE47D08E4C
2 changed files with 6 additions and 9 deletions

View File

@ -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

View File

@ -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