25 lines
486 B
Elixir
25 lines
486 B
Elixir
defmodule Prymn.Agents.Connection do
|
|
@moduledoc false
|
|
use GenServer, restart: :transient
|
|
|
|
def start_link(host_address) do
|
|
GenServer.start_link(__MODULE__, host_address, name: via(host_address))
|
|
end
|
|
|
|
def get_channel(server) when is_pid(server) do
|
|
GenServer.call(server, :get_channel)
|
|
end
|
|
|
|
##
|
|
## Server callbacks
|
|
##
|
|
|
|
@impl true
|
|
def init(host) do
|
|
{:ok, {host, nil}}
|
|
end
|
|
|
|
defp via(name) do
|
|
{:via, Registry, {Prymn.Agents.Registry, name}}
|
|
end
|
|
end
|