little polishing

This commit is contained in:
Alexander Strizhakov 2020-03-06 21:24:19 +03:00
parent c93c3096d5
commit 78282dc983
No known key found for this signature in database
GPG key ID: 022896A53AEF1381
4 changed files with 14 additions and 12 deletions

View file

@ -5,11 +5,11 @@
defmodule Pleroma.HTTP.AdapterHelper.Gun do
@behaviour Pleroma.HTTP.AdapterHelper
require Logger
alias Pleroma.HTTP.AdapterHelper
alias Pleroma.Pool.Connections
require Logger
@defaults [
connect_timeout: 5_000,
domain_lookup_timeout: 5_000,

View file

@ -13,8 +13,10 @@ defmodule Pleroma.HTTP.AdapterHelper.Hackney do
def options(connection_opts \\ [], %URI{} = uri) do
proxy = Pleroma.Config.get([:http, :proxy_url], nil)
config_opts = Pleroma.Config.get([:http, :adapter], [])
@defaults
|> Keyword.merge(Pleroma.Config.get([:http, :adapter], []))
|> Keyword.merge(config_opts)
|> Keyword.merge(connection_opts)
|> add_scheme_opts(uri)
|> Pleroma.HTTP.AdapterHelper.maybe_add_proxy(proxy)

View file

@ -6,6 +6,14 @@ defmodule Pleroma.HTTP.Connection do
@moduledoc """
Configure Tesla.Client with default and customized adapter options.
"""
alias Pleroma.Config
alias Pleroma.HTTP.AdapterHelper
require Logger
@defaults [pool: :federation]
@type ip_address :: ipv4_address() | ipv6_address()
@type ipv4_address :: {0..255, 0..255, 0..255, 0..255}
@type ipv6_address ::
@ -13,13 +21,6 @@ defmodule Pleroma.HTTP.Connection do
@type proxy_type() :: :socks4 | :socks5
@type host() :: charlist() | ip_address()
@defaults [pool: :federation]
require Logger
alias Pleroma.Config
alias Pleroma.HTTP.AdapterHelper
@doc """
Merge default connection & adapter options with received ones.
"""

View file

@ -6,6 +6,7 @@ defmodule Pleroma.Pool.Connections do
use GenServer
alias Pleroma.Config
alias Pleroma.Gun
require Logger
@ -19,8 +20,6 @@ defmodule Pleroma.Pool.Connections do
defstruct conns: %{}, opts: []
alias Pleroma.Gun
@spec start_link({atom(), keyword()}) :: {:ok, pid()}
def start_link({name, opts}) do
GenServer.start_link(__MODULE__, opts, name: name)