diff options
author | href <href@random.sh> | 2020-07-07 18:56:17 +0200 |
---|---|---|
committer | rinpatch <rinpatch@sdf.org> | 2020-07-15 15:26:35 +0300 |
commit | 46dd276d686e49676101e2af743aad61393f4b70 (patch) | |
tree | cbd4df2d7793250d5616be9d0a171b15ed5874a2 | |
parent | 33747e9366ef7422c9b39ac360ad1d96405bc4fd (diff) | |
download | pleroma-46dd276d686e49676101e2af743aad61393f4b70.tar.gz |
ConnectionPool.Worker: Open gun conn in continue instead of init
-rw-r--r-- | lib/pleroma/gun/connection_pool/worker.ex | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/pleroma/gun/connection_pool/worker.ex b/lib/pleroma/gun/connection_pool/worker.ex index ec0502621..6ee622fb0 100644 --- a/lib/pleroma/gun/connection_pool/worker.ex +++ b/lib/pleroma/gun/connection_pool/worker.ex @@ -9,7 +9,12 @@ defmodule Pleroma.Gun.ConnectionPool.Worker 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 @@ defmodule Pleroma.Gun.ConnectionPool.Worker do send(client_pid, {:conn_pid, conn_pid}) - {:ok, + {:noreply, %{key: key, timer: nil, client_monitors: %{client_pid => Process.monitor(client_pid)}}, :hibernate} else |