forked from AkkomaGang/akkoma
ConnectionPool.Worker: Open gun conn in continue instead of init
This commit is contained in:
parent
33747e9366
commit
46dd276d68
1 changed files with 7 additions and 2 deletions
|
@ -9,7 +9,12 @@ def start_link([key | _] = opts) do
|
|||
end
|
||||
|
||||
@impl true
|
||||
def init([key, uri, opts, client_pid]) do
|
||||
def init([_key, _uri, _opts, _client_pid] = opts) do
|
||||
{:ok, nil, {:continue, {:connect, opts}}}
|
||||
end
|
||||
|
||||
@impl true
|
||||
def handle_continue({:connect, [key, uri, opts, client_pid]}, _) do
|
||||
with {:ok, conn_pid} <- Gun.Conn.open(uri, opts),
|
||||
Process.link(conn_pid) do
|
||||
time = :erlang.monotonic_time(:millisecond)
|
||||
|
@ -21,7 +26,7 @@ def init([key, uri, opts, client_pid]) do
|
|||
|
||||
send(client_pid, {:conn_pid, conn_pid})
|
||||
|
||||
{:ok,
|
||||
{:noreply,
|
||||
%{key: key, timer: nil, client_monitors: %{client_pid => Process.monitor(client_pid)}},
|
||||
:hibernate}
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue