mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-12-23 08:36:29 +00:00
Set a default timeout for Gun adapter timeout
This commit is contained in:
parent
e499275076
commit
6d583bcc3b
1 changed files with 5 additions and 3 deletions
|
@ -44,15 +44,17 @@ defmodule Pleroma.HTTP.AdapterHelper do
|
||||||
@spec options(URI.t(), keyword()) :: keyword()
|
@spec options(URI.t(), keyword()) :: keyword()
|
||||||
def options(%URI{} = uri, opts \\ []) do
|
def options(%URI{} = uri, opts \\ []) do
|
||||||
@defaults
|
@defaults
|
||||||
|> pool_timeout()
|
|> put_timeout()
|
||||||
|> Keyword.merge(opts)
|
|> Keyword.merge(opts)
|
||||||
|> adapter_helper().options(uri)
|
|> adapter_helper().options(uri)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp pool_timeout(opts) do
|
# For Hackney, this is the time a connection can stay idle in the pool.
|
||||||
|
# For Gun, this is the timeout to receive a message from Gun.
|
||||||
|
defp put_timeout(opts) do
|
||||||
{config_key, default} =
|
{config_key, default} =
|
||||||
if adapter() == Tesla.Adapter.Gun do
|
if adapter() == Tesla.Adapter.Gun do
|
||||||
{:pools, Config.get([:pools, :default, :timeout])}
|
{:pools, Config.get([:pools, :default, :timeout], 5_000)}
|
||||||
else
|
else
|
||||||
{:hackney_pools, 10_000}
|
{:hackney_pools, 10_000}
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue