gun: connection pool: allow the connection pool to be started with a name when appropriate

This commit is contained in:
Ariadne Conill 2019-08-19 00:00:22 +00:00
parent a53a450550
commit 337340c3a1

View File

@ -13,8 +13,14 @@ defmodule Pleroma.Gun.Connections do
defstruct conns: %{} defstruct conns: %{}
def start_link(name \\ __MODULE__)
def start_link(name) when is_atom(name) do
GenServer.start_link(__MODULE__, [], name: name)
end
def start_link(_) do def start_link(_) do
if Application.get_env(:tesla, :adapter) == Tesla.Adapter.Gun || Mix.env() == :test do if Application.get_env(:tesla, :adapter) == Tesla.Adapter.Gun do
GenServer.start_link(__MODULE__, []) GenServer.start_link(__MODULE__, [])
else else
:ignore :ignore