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,
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)
@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 ::
@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.
"""
use GenServer
alias Pleroma.Config
+ alias Pleroma.Gun
require Logger
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)