by default don't use gun retries
remove conn depends on retry setting from config
This commit is contained in:
parent
3849bbb60d
commit
a03c420b84
@ -599,7 +599,7 @@
|
|||||||
config :pleroma, :connections_pool,
|
config :pleroma, :connections_pool,
|
||||||
receive_connection_timeout: 250,
|
receive_connection_timeout: 250,
|
||||||
max_connections: 250,
|
max_connections: 250,
|
||||||
retry: 5,
|
retry: 0,
|
||||||
retry_timeout: 100,
|
retry_timeout: 100,
|
||||||
await_up_timeout: 5_000
|
await_up_timeout: 5_000
|
||||||
|
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
defmodule Pleroma.Pool.Connections do
|
defmodule Pleroma.Pool.Connections do
|
||||||
use GenServer
|
use GenServer
|
||||||
|
|
||||||
|
alias Pleroma.Config
|
||||||
|
|
||||||
require Logger
|
require Logger
|
||||||
|
|
||||||
@type domain :: String.t()
|
@type domain :: String.t()
|
||||||
@ -33,7 +35,7 @@ def checkin(url, name)
|
|||||||
def checkin(url, name) when is_binary(url), do: checkin(URI.parse(url), name)
|
def checkin(url, name) when is_binary(url), do: checkin(URI.parse(url), name)
|
||||||
|
|
||||||
def checkin(%URI{} = uri, name) do
|
def checkin(%URI{} = uri, name) do
|
||||||
timeout = Pleroma.Config.get([:connections_pool, :receive_connection_timeout], 250)
|
timeout = Config.get([:connections_pool, :receive_connection_timeout], 250)
|
||||||
|
|
||||||
GenServer.call(
|
GenServer.call(
|
||||||
name,
|
name,
|
||||||
@ -47,7 +49,7 @@ def open_conn(url, name, opts \\ [])
|
|||||||
def open_conn(url, name, opts) when is_binary(url), do: open_conn(URI.parse(url), name, opts)
|
def open_conn(url, name, opts) when is_binary(url), do: open_conn(URI.parse(url), name, opts)
|
||||||
|
|
||||||
def open_conn(%URI{} = uri, name, opts) do
|
def open_conn(%URI{} = uri, name, opts) do
|
||||||
pool_opts = Pleroma.Config.get([:connections_pool], [])
|
pool_opts = Config.get([:connections_pool], [])
|
||||||
|
|
||||||
opts =
|
opts =
|
||||||
opts
|
opts
|
||||||
@ -193,12 +195,13 @@ def handle_info({:gun_up, conn_pid, _protocol}, state) do
|
|||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def handle_info({:gun_down, conn_pid, _protocol, _reason, _killed}, state) do
|
def handle_info({:gun_down, conn_pid, _protocol, _reason, _killed}, state) do
|
||||||
|
retries = Config.get([:connections_pool, :retry], 0)
|
||||||
# we can't get info on this pid, because pid is dead
|
# we can't get info on this pid, because pid is dead
|
||||||
state =
|
state =
|
||||||
with true <- Process.alive?(conn_pid),
|
with true <- Process.alive?(conn_pid),
|
||||||
{key, conn} <- find_conn(state.conns, conn_pid) do
|
{key, conn} <- find_conn(state.conns, conn_pid) do
|
||||||
if conn.retries == 5 do
|
if conn.retries == retries do
|
||||||
Logger.debug("closing conn if retries is eq 5 #{inspect(conn_pid)}")
|
Logger.debug("closing conn if retries is eq #{inspect(conn_pid)}")
|
||||||
:ok = API.close(conn.conn)
|
:ok = API.close(conn.conn)
|
||||||
|
|
||||||
put_in(
|
put_in(
|
||||||
|
Loading…
Reference in New Issue
Block a user