diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/gun/api/api.ex | 2 | ||||
-rw-r--r-- | lib/pleroma/gun/api/gun.ex | 22 | ||||
-rw-r--r-- | lib/pleroma/gun/connections.ex | 17 |
3 files changed, 24 insertions, 17 deletions
diff --git a/lib/pleroma/gun/api/api.ex b/lib/pleroma/gun/api/api.ex index c69ab890e..19adc1bf0 100644 --- a/lib/pleroma/gun/api/api.ex +++ b/lib/pleroma/gun/api/api.ex @@ -10,6 +10,6 @@ defmodule Pleroma.Gun.API do end defp api do - Pleroma.Config.get([Pleroma.Gun.API], :gun) + Pleroma.Config.get([Pleroma.Gun.API], Pleroma.Gun.API.Gun) end end diff --git a/lib/pleroma/gun/api/gun.ex b/lib/pleroma/gun/api/gun.ex new file mode 100644 index 000000000..14a4b7275 --- /dev/null +++ b/lib/pleroma/gun/api/gun.ex @@ -0,0 +1,22 @@ +defmodule Pleroma.Gun.API.Gun do + @behaviour Pleroma.Gun.API + + @gun_keys [ + :connect_timeout, + :http_opts, + :http2_opts, + :protocols, + :retry, + :retry_timeout, + :trace, + :transport, + :tls_opts, + :tcp_opts, + :ws_opts + ] + + @impl Pleroma.Gun.API + def open(host, port, opts) do + :gun.open(host, port, Map.take(opts, @gun_keys)) + end +end diff --git a/lib/pleroma/gun/connections.ex b/lib/pleroma/gun/connections.ex index b8cf2f9b5..a3f1b0351 100644 --- a/lib/pleroma/gun/connections.ex +++ b/lib/pleroma/gun/connections.ex @@ -11,20 +11,6 @@ defmodule Pleroma.Gun.Connections do conns: %{domain() => conn()} } - @gun_keys [ - :connect_timeout, - :http_opts, - :http2_opts, - :protocols, - :retry, - :retry_timeout, - :trace, - :transport, - :tls_opts, - :tcp_opts, - :ws_opts - ] - defstruct conns: %{} def start_link(name \\ __MODULE__) do @@ -95,8 +81,7 @@ defmodule Pleroma.Gun.Connections do {:noreply, state} nil -> - {:ok, conn} = - Pleroma.Gun.API.open(to_charlist(uri.host), uri.port, Map.take(opts, @gun_keys)) + {:ok, conn} = Pleroma.Gun.API.open(to_charlist(uri.host), uri.port, opts) state = put_in(state.conns[key], %Pleroma.Gun.Conn{ |