little polishing
This commit is contained in:
parent
c93c3096d5
commit
78282dc983
4 changed files with 14 additions and 12 deletions
|
@ -5,11 +5,11 @@
|
||||||
defmodule Pleroma.HTTP.AdapterHelper.Gun do
|
defmodule Pleroma.HTTP.AdapterHelper.Gun do
|
||||||
@behaviour Pleroma.HTTP.AdapterHelper
|
@behaviour Pleroma.HTTP.AdapterHelper
|
||||||
|
|
||||||
require Logger
|
|
||||||
|
|
||||||
alias Pleroma.HTTP.AdapterHelper
|
alias Pleroma.HTTP.AdapterHelper
|
||||||
alias Pleroma.Pool.Connections
|
alias Pleroma.Pool.Connections
|
||||||
|
|
||||||
|
require Logger
|
||||||
|
|
||||||
@defaults [
|
@defaults [
|
||||||
connect_timeout: 5_000,
|
connect_timeout: 5_000,
|
||||||
domain_lookup_timeout: 5_000,
|
domain_lookup_timeout: 5_000,
|
||||||
|
|
|
@ -13,8 +13,10 @@ defmodule Pleroma.HTTP.AdapterHelper.Hackney do
|
||||||
def options(connection_opts \\ [], %URI{} = uri) do
|
def options(connection_opts \\ [], %URI{} = uri) do
|
||||||
proxy = Pleroma.Config.get([:http, :proxy_url], nil)
|
proxy = Pleroma.Config.get([:http, :proxy_url], nil)
|
||||||
|
|
||||||
|
config_opts = Pleroma.Config.get([:http, :adapter], [])
|
||||||
|
|
||||||
@defaults
|
@defaults
|
||||||
|> Keyword.merge(Pleroma.Config.get([:http, :adapter], []))
|
|> Keyword.merge(config_opts)
|
||||||
|> Keyword.merge(connection_opts)
|
|> Keyword.merge(connection_opts)
|
||||||
|> add_scheme_opts(uri)
|
|> add_scheme_opts(uri)
|
||||||
|> Pleroma.HTTP.AdapterHelper.maybe_add_proxy(proxy)
|
|> Pleroma.HTTP.AdapterHelper.maybe_add_proxy(proxy)
|
||||||
|
|
|
@ -6,6 +6,14 @@ defmodule Pleroma.HTTP.Connection do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Configure Tesla.Client with default and customized adapter options.
|
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 ip_address :: ipv4_address() | ipv6_address()
|
||||||
@type ipv4_address :: {0..255, 0..255, 0..255, 0..255}
|
@type ipv4_address :: {0..255, 0..255, 0..255, 0..255}
|
||||||
@type ipv6_address ::
|
@type ipv6_address ::
|
||||||
|
@ -13,13 +21,6 @@ defmodule Pleroma.HTTP.Connection do
|
||||||
@type proxy_type() :: :socks4 | :socks5
|
@type proxy_type() :: :socks4 | :socks5
|
||||||
@type host() :: charlist() | ip_address()
|
@type host() :: charlist() | ip_address()
|
||||||
|
|
||||||
@defaults [pool: :federation]
|
|
||||||
|
|
||||||
require Logger
|
|
||||||
|
|
||||||
alias Pleroma.Config
|
|
||||||
alias Pleroma.HTTP.AdapterHelper
|
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
Merge default connection & adapter options with received ones.
|
Merge default connection & adapter options with received ones.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -6,6 +6,7 @@ defmodule Pleroma.Pool.Connections do
|
||||||
use GenServer
|
use GenServer
|
||||||
|
|
||||||
alias Pleroma.Config
|
alias Pleroma.Config
|
||||||
|
alias Pleroma.Gun
|
||||||
|
|
||||||
require Logger
|
require Logger
|
||||||
|
|
||||||
|
@ -19,8 +20,6 @@ defmodule Pleroma.Pool.Connections do
|
||||||
|
|
||||||
defstruct conns: %{}, opts: []
|
defstruct conns: %{}, opts: []
|
||||||
|
|
||||||
alias Pleroma.Gun
|
|
||||||
|
|
||||||
@spec start_link({atom(), keyword()}) :: {:ok, pid()}
|
@spec start_link({atom(), keyword()}) :: {:ok, pid()}
|
||||||
def start_link({name, opts}) do
|
def start_link({name, opts}) do
|
||||||
GenServer.start_link(__MODULE__, opts, name: name)
|
GenServer.start_link(__MODULE__, opts, name: name)
|
||||||
|
|
Loading…
Reference in a new issue