mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-13 03:01:12 +00:00
Connection Pool: don't enforce pool limits if no new connection needs to be opened
This commit is contained in:
parent
58a4f350a8
commit
fffbcffb8c
|
@ -2,8 +2,6 @@ defmodule Pleroma.Gun.ConnectionPool do
|
|||
@registry __MODULE__
|
||||
|
||||
def get_conn(uri, opts) do
|
||||
case enforce_pool_limits() do
|
||||
:ok ->
|
||||
key = "#{uri.scheme}:#{uri.host}:#{uri.port}"
|
||||
|
||||
case Registry.lookup(@registry, key) do
|
||||
|
@ -16,6 +14,8 @@ defmodule Pleroma.Gun.ConnectionPool do
|
|||
{:ok, gun_pid}
|
||||
|
||||
[] ->
|
||||
case enforce_pool_limits() do
|
||||
:ok ->
|
||||
# :gun.set_owner fails in :connected state for whatevever reason,
|
||||
# so we open the connection in the process directly and send it's pid back
|
||||
# We trust gun to handle timeouts by itself
|
||||
|
@ -33,12 +33,12 @@ defmodule Pleroma.Gun.ConnectionPool do
|
|||
err ->
|
||||
err
|
||||
end
|
||||
end
|
||||
|
||||
:error ->
|
||||
{:error, :pool_full}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@enforcer_key "enforcer"
|
||||
defp enforce_pool_limits() do
|
||||
|
|
Loading…
Reference in a new issue