removing retry option and changing some logger messages levels
This commit is contained in:
parent
138a3c1fe4
commit
c9db0507f8
@ -15,7 +15,7 @@ defmodule Pleroma.HTTP.Adapter.Gun do
|
|||||||
connect_timeout: 20_000,
|
connect_timeout: 20_000,
|
||||||
domain_lookup_timeout: 5_000,
|
domain_lookup_timeout: 5_000,
|
||||||
tls_handshake_timeout: 5_000,
|
tls_handshake_timeout: 5_000,
|
||||||
retry_timeout: 100,
|
retry: 0,
|
||||||
await_up_timeout: 5_000
|
await_up_timeout: 5_000
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ defmodule Pleroma.HTTP.Adapter.Gun do
|
|||||||
try do
|
try do
|
||||||
case Connections.checkin(uri, :gun_connections) do
|
case Connections.checkin(uri, :gun_connections) do
|
||||||
nil ->
|
nil ->
|
||||||
Logger.info(
|
Logger.debug(
|
||||||
"Gun connections pool checkin was not successful. Trying to open conn for next request."
|
"Gun connections pool checkin was not successful. Trying to open conn for next request."
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -97,7 +97,9 @@ defmodule Pleroma.HTTP.Adapter.Gun do
|
|||||||
opts
|
opts
|
||||||
|
|
||||||
conn when is_pid(conn) ->
|
conn when is_pid(conn) ->
|
||||||
Logger.debug("received conn #{inspect(conn)} #{Connections.compose_uri(uri)}")
|
Logger.debug(
|
||||||
|
"received conn #{inspect(conn)} #{uri.scheme}://#{Connections.compose_uri(uri)}"
|
||||||
|
)
|
||||||
|
|
||||||
opts
|
opts
|
||||||
|> Keyword.put(:conn, conn)
|
|> Keyword.put(:conn, conn)
|
||||||
@ -105,18 +107,30 @@ defmodule Pleroma.HTTP.Adapter.Gun do
|
|||||||
end
|
end
|
||||||
rescue
|
rescue
|
||||||
error ->
|
error ->
|
||||||
Logger.warn("Gun connections pool checkin caused error #{inspect(error)}")
|
Logger.warn(
|
||||||
|
"Gun connections pool checkin caused error #{uri.scheme}://#{
|
||||||
|
Connections.compose_uri(uri)
|
||||||
|
} #{inspect(error)}"
|
||||||
|
)
|
||||||
|
|
||||||
opts
|
opts
|
||||||
catch
|
catch
|
||||||
:exit, {:timeout, _} ->
|
:exit, {:timeout, _} ->
|
||||||
Logger.info(
|
Logger.warn(
|
||||||
"Gun connections pool checkin with timeout error #{Connections.compose_uri(uri)}"
|
"Gun connections pool checkin with timeout error #{uri.scheme}://#{
|
||||||
|
Connections.compose_uri(uri)
|
||||||
|
}"
|
||||||
)
|
)
|
||||||
|
|
||||||
opts
|
opts
|
||||||
|
|
||||||
:exit, error ->
|
:exit, error ->
|
||||||
Logger.warn("Gun pool checkin exited with error #{inspect(error)}")
|
Logger.warn(
|
||||||
|
"Gun pool checkin exited with error #{uri.scheme}://#{Connections.compose_uri(uri)} #{
|
||||||
|
inspect(error)
|
||||||
|
}"
|
||||||
|
)
|
||||||
|
|
||||||
opts
|
opts
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -52,8 +52,7 @@ defmodule Pleroma.Pool.Connections do
|
|||||||
opts =
|
opts =
|
||||||
opts
|
opts
|
||||||
|> Enum.into(%{})
|
|> Enum.into(%{})
|
||||||
|> Map.put_new(:receive, false)
|
|> Map.put_new(:retry, pool_opts[:retry] || 0)
|
||||||
|> Map.put_new(:retry, pool_opts[:retry] || 5)
|
|
||||||
|> Map.put_new(:retry_timeout, pool_opts[:retry_timeout] || 100)
|
|> Map.put_new(:retry_timeout, pool_opts[:retry_timeout] || 100)
|
||||||
|> Map.put_new(:await_up_timeout, pool_opts[:await_up_timeout] || 5_000)
|
|> Map.put_new(:await_up_timeout, pool_opts[:await_up_timeout] || 5_000)
|
||||||
|
|
||||||
@ -108,11 +107,11 @@ defmodule Pleroma.Pool.Connections do
|
|||||||
put_in(state.conns[key], %{conn | conn_state: conn_state, used_by: used_by})
|
put_in(state.conns[key], %{conn | conn_state: conn_state, used_by: used_by})
|
||||||
else
|
else
|
||||||
false ->
|
false ->
|
||||||
Logger.warn("checkout for closed conn #{inspect(conn_pid)}")
|
Logger.debug("checkout for closed conn #{inspect(conn_pid)}")
|
||||||
state
|
state
|
||||||
|
|
||||||
nil ->
|
nil ->
|
||||||
Logger.info("checkout for alive conn #{inspect(conn_pid)}, but is not in state")
|
Logger.debug("checkout for alive conn #{inspect(conn_pid)}, but is not in state")
|
||||||
state
|
state
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -172,15 +171,15 @@ defmodule Pleroma.Pool.Connections do
|
|||||||
})
|
})
|
||||||
else
|
else
|
||||||
:error_gun_info ->
|
:error_gun_info ->
|
||||||
Logger.warn(":gun.info caused error")
|
Logger.debug(":gun.info caused error")
|
||||||
state
|
state
|
||||||
|
|
||||||
false ->
|
false ->
|
||||||
Logger.warn(":gun_up message for closed conn #{inspect(conn_pid)}")
|
Logger.debug(":gun_up message for closed conn #{inspect(conn_pid)}")
|
||||||
state
|
state
|
||||||
|
|
||||||
nil ->
|
nil ->
|
||||||
Logger.warn(
|
Logger.debug(
|
||||||
":gun_up message for alive conn #{inspect(conn_pid)}, but deleted from state"
|
":gun_up message for alive conn #{inspect(conn_pid)}, but deleted from state"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -216,11 +215,11 @@ defmodule Pleroma.Pool.Connections do
|
|||||||
else
|
else
|
||||||
false ->
|
false ->
|
||||||
# gun can send gun_down for closed conn, maybe connection is not closed yet
|
# gun can send gun_down for closed conn, maybe connection is not closed yet
|
||||||
Logger.warn(":gun_down message for closed conn #{inspect(conn_pid)}")
|
Logger.debug(":gun_down message for closed conn #{inspect(conn_pid)}")
|
||||||
state
|
state
|
||||||
|
|
||||||
nil ->
|
nil ->
|
||||||
Logger.warn(
|
Logger.debug(
|
||||||
":gun_down message for alive conn #{inspect(conn_pid)}, but deleted from state"
|
":gun_down message for alive conn #{inspect(conn_pid)}, but deleted from state"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ defmodule Pleroma.HTTP.Adapter.GunTest do
|
|||||||
|
|
||||||
test "get conn on next request" do
|
test "get conn on next request" do
|
||||||
level = Application.get_env(:logger, :level)
|
level = Application.get_env(:logger, :level)
|
||||||
Logger.configure(level: :info)
|
Logger.configure(level: :debug)
|
||||||
on_exit(fn -> Logger.configure(level: level) end)
|
on_exit(fn -> Logger.configure(level: level) end)
|
||||||
uri = URI.parse("http://some-domain2.com")
|
uri = URI.parse("http://some-domain2.com")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user