d34fe2840d
Use a custom tesla middleware instead of adapter helper function + custom redirect middleware. This will also fix "Client died before releasing the connection" messages when the request pool is overloaded. Since the checkout is now done after passing ConcurrentLimiter. This is technically less efficient, since the connection needs to be checked in/out every time the middleware is left or entered respectively. But I don't think the nanoseconds we might lose on redirects to the same host are worth the complexity.
27 lines
679 B
Elixir
27 lines
679 B
Elixir
defmodule Pleroma.HTTP.AdapterHelper.Hackney do
|
|
@behaviour Pleroma.HTTP.AdapterHelper
|
|
|
|
@defaults [
|
|
connect_timeout: 10_000,
|
|
recv_timeout: 20_000,
|
|
follow_redirect: true,
|
|
force_redirect: true,
|
|
pool: :federation
|
|
]
|
|
|
|
@spec options(keyword(), URI.t()) :: keyword()
|
|
def options(connection_opts \\ [], %URI{} = uri) do
|
|
proxy = Pleroma.Config.get([:http, :proxy_url])
|
|
|
|
config_opts = Pleroma.Config.get([:http, :adapter], [])
|
|
|
|
@defaults
|
|
|> Keyword.merge(config_opts)
|
|
|> Keyword.merge(connection_opts)
|
|
|> add_scheme_opts(uri)
|
|
|> Pleroma.HTTP.AdapterHelper.maybe_add_proxy(proxy)
|
|
end
|
|
|
|
defp add_scheme_opts(opts, _), do: opts
|
|
end
|