diff --git a/lib/chronoscope/nts.ex b/lib/chronoscope/nts.ex index 0e84813..6d211d6 100644 --- a/lib/chronoscope/nts.ex +++ b/lib/chronoscope/nts.ex @@ -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 diff --git a/lib/chronoscope/nts/client.ex b/lib/chronoscope/nts/client.ex index 71dc28b..d1fff9c 100644 --- a/lib/chronoscope/nts/client.ex +++ b/lib/chronoscope/nts/client.ex @@ -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