projects
/
akkoma
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
39ed608
)
more clean up
author
Alexander Strizhakov
<alex.strizhakov@gmail.com>
Fri, 13 Mar 2020 06:37:57 +0000
(09:37 +0300)
committer
Alexander Strizhakov
<alex.strizhakov@gmail.com>
Fri, 13 Mar 2020 06:37:57 +0000
(09:37 +0300)
lib/pleroma/http/adapter_helper/gun.ex
patch
|
blob
|
history
lib/pleroma/http/adapter_helper/hackney.ex
patch
|
blob
|
history
lib/pleroma/http/connection.ex
patch
|
blob
|
history
lib/pleroma/pool/request.ex
patch
|
blob
|
history
lib/pleroma/pool/supervisor.ex
patch
|
blob
|
history
lib/pleroma/reverse_proxy/client/tesla.ex
patch
|
blob
|
history
lib/pleroma/reverse_proxy/reverse_proxy.ex
patch
|
blob
|
history
diff --git
a/lib/pleroma/http/adapter_helper/gun.ex
b/lib/pleroma/http/adapter_helper/gun.ex
index f14b95c19f5d64ddce8964f68d0abf7329b53109..ead7cdc6bba7297f1b6ceaa1faf4a6687e48c979 100644
(file)
--- a/
lib/pleroma/http/adapter_helper/gun.ex
+++ b/
lib/pleroma/http/adapter_helper/gun.ex
@@
-22,7
+22,7
@@
defmodule Pleroma.HTTP.AdapterHelper.Gun do
@spec options(keyword(), URI.t()) :: keyword()
def options(incoming_opts \\ [], %URI{} = uri) do
proxy =
@spec options(keyword(), URI.t()) :: keyword()
def options(incoming_opts \\ [], %URI{} = uri) do
proxy =
- Pleroma.Config.get([:http, :proxy_url]
, nil
)
+ Pleroma.Config.get([:http, :proxy_url])
|> AdapterHelper.format_proxy()
config_opts = Pleroma.Config.get([:http, :adapter], [])
|> AdapterHelper.format_proxy()
config_opts = Pleroma.Config.get([:http, :adapter], [])
diff --git
a/lib/pleroma/http/adapter_helper/hackney.ex
b/lib/pleroma/http/adapter_helper/hackney.ex
index d08afae0cab5d43f89bf68d091cf1780acf9d9b7..dcb4cac71966de2e3cddfafe1bf122ccd4e2f77d 100644
(file)
--- a/
lib/pleroma/http/adapter_helper/hackney.ex
+++ b/
lib/pleroma/http/adapter_helper/hackney.ex
@@
-11,7
+11,7
@@
defmodule Pleroma.HTTP.AdapterHelper.Hackney do
@spec options(keyword(), URI.t()) :: keyword()
def options(connection_opts \\ [], %URI{} = uri) do
@spec options(keyword(), URI.t()) :: keyword()
def options(connection_opts \\ [], %URI{} = uri) do
- proxy = Pleroma.Config.get([:http, :proxy_url]
, nil
)
+ proxy = Pleroma.Config.get([:http, :proxy_url])
config_opts = Pleroma.Config.get([:http, :adapter], [])
config_opts = Pleroma.Config.get([:http, :adapter], [])
diff --git
a/lib/pleroma/http/connection.ex
b/lib/pleroma/http/connection.ex
index 76de3fcfe009e5cb0f7815299503186f6278b522..ebacf7902e2c9b10523c7c25d80b70841ef5b841 100644
(file)
--- a/
lib/pleroma/http/connection.ex
+++ b/
lib/pleroma/http/connection.ex
@@
-30,12
+30,12
@@
defmodule Pleroma.HTTP.Connection do
@defaults
|> pool_timeout()
|> Keyword.merge(opts)
@defaults
|> pool_timeout()
|> Keyword.merge(opts)
- |> adapter().options(uri)
+ |> adapter
_helper
().options(uri)
end
defp pool_timeout(opts) do
{config_key, default} =
end
defp pool_timeout(opts) do
{config_key, default} =
- if
Application.get_env(:tesla, :adapter
) == Tesla.Adapter.Gun do
+ if
adapter(
) == Tesla.Adapter.Gun do
{:pools, Config.get([:pools, :default, :timeout])}
else
{:hackney_pools, 10_000}
{:pools, Config.get([:pools, :default, :timeout])}
else
{:hackney_pools, 10_000}
@@
-47,10
+47,12
@@
defmodule Pleroma.HTTP.Connection do
end
@spec after_request(keyword()) :: :ok
end
@spec after_request(keyword()) :: :ok
- def after_request(opts), do: adapter().after_request(opts)
+ def after_request(opts), do: adapter
_helper
().after_request(opts)
- defp adapter do
- case Application.get_env(:tesla, :adapter) do
+ defp adapter, do: Application.get_env(:tesla, :adapter)
+
+ defp adapter_helper do
+ case adapter() do
Tesla.Adapter.Gun -> AdapterHelper.Gun
Tesla.Adapter.Hackney -> AdapterHelper.Hackney
_ -> AdapterHelper
Tesla.Adapter.Gun -> AdapterHelper.Gun
Tesla.Adapter.Hackney -> AdapterHelper.Hackney
_ -> AdapterHelper
diff --git
a/lib/pleroma/pool/request.ex
b/lib/pleroma/pool/request.ex
index db7c10c01f7c51d91e9cc9a3cee38f5b63588fe1..3fb930db72fbb51d4d7fcac9011b64b4efa03c29 100644
(file)
--- a/
lib/pleroma/pool/request.ex
+++ b/
lib/pleroma/pool/request.ex
@@
-39,7
+39,6
@@
defmodule Pleroma.Pool.Request do
@impl true
def handle_info({:gun_down, _conn, _protocol, _reason, _killed}, state) do
@impl true
def handle_info({:gun_down, _conn, _protocol, _reason, _killed}, state) do
- # don't flush messages here, because gun can reconnect
{:noreply, state}
end
{:noreply, state}
end
diff --git
a/lib/pleroma/pool/supervisor.ex
b/lib/pleroma/pool/supervisor.ex
index 8dc5b64b727774328e7b315b18722cbf31201b7a..faf646cb2b09cb498fbe15afc8f151eb91c8fa32 100644
(file)
--- a/
lib/pleroma/pool/supervisor.ex
+++ b/
lib/pleroma/pool/supervisor.ex
@@
-13,16
+13,13
@@
defmodule Pleroma.Pool.Supervisor do
end
def init(_) do
end
def init(_) do
- children =
- [
- %{
- id: Pool.Connections,
- start:
- {Pool.Connections, :start_link, [{:gun_connections, Config.get([:connections_pool])}]}
- }
- ] ++ pools()
-
- Supervisor.init(children, strategy: :one_for_one)
+ conns_child = %{
+ id: Pool.Connections,
+ start:
+ {Pool.Connections, :start_link, [{:gun_connections, Config.get([:connections_pool])}]}
+ }
+
+ Supervisor.init([conns_child | pools()], strategy: :one_for_one)
end
defp pools do
end
defp pools do
diff --git
a/lib/pleroma/reverse_proxy/client/tesla.ex
b/lib/pleroma/reverse_proxy/client/tesla.ex
index dbc6b66a3d87f791ef037df042f61eb6412fd95a..e81ea8bde135be2045ce88b7ad292a7f6780a231 100644
(file)
--- a/
lib/pleroma/reverse_proxy/client/tesla.ex
+++ b/
lib/pleroma/reverse_proxy/client/tesla.ex
@@
-3,11
+3,11
@@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.ReverseProxy.Client.Tesla do
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.ReverseProxy.Client.Tesla do
+ @behaviour Pleroma.ReverseProxy.Client
+
@type headers() :: [{String.t(), String.t()}]
@type status() :: pos_integer()
@type headers() :: [{String.t(), String.t()}]
@type status() :: pos_integer()
- @behaviour Pleroma.ReverseProxy.Client
-
@spec request(atom(), String.t(), headers(), String.t(), keyword()) ::
{:ok, status(), headers}
| {:ok, status(), headers, map()}
@spec request(atom(), String.t(), headers(), String.t(), keyword()) ::
{:ok, status(), headers}
| {:ok, status(), headers, map()}
@@
-18,7
+18,7
@@
defmodule Pleroma.ReverseProxy.Client.Tesla do
def request(method, url, headers, body, opts \\ []) do
check_adapter()
def request(method, url, headers, body, opts \\ []) do
check_adapter()
- opts = Keyword.
merge(opts, body_as:
:chunks)
+ opts = Keyword.
put(opts, :body_as,
:chunks)
with {:ok, response} <-
Pleroma.HTTP.request(
with {:ok, response} <-
Pleroma.HTTP.request(
@@
-39,7
+39,8
@@
defmodule Pleroma.ReverseProxy.Client.Tesla do
end
@impl true
end
@impl true
- @spec stream_body(map()) :: {:ok, binary(), map()} | {:error, atom() | String.t()} | :done
+ @spec stream_body(map()) ::
+ {:ok, binary(), map()} | {:error, atom() | String.t()} | :done | no_return()
def stream_body(%{pid: pid, opts: opts, fin: true}) do
# if connection was reused, but in tesla were redirects,
# tesla returns new opened connection, which must be closed manually
def stream_body(%{pid: pid, opts: opts, fin: true}) do
# if connection was reused, but in tesla were redirects,
# tesla returns new opened connection, which must be closed manually
diff --git
a/lib/pleroma/reverse_proxy/reverse_proxy.ex
b/lib/pleroma/reverse_proxy/reverse_proxy.ex
index 8f1aa320075311f9fcf8286b12b8289cd8daf6c7..35b973b564a3b373f0be96c5bb0b0e6f507c136a 100644
(file)
--- a/
lib/pleroma/reverse_proxy/reverse_proxy.ex
+++ b/
lib/pleroma/reverse_proxy/reverse_proxy.ex
@@
-59,7
+59,7
@@
defmodule Pleroma.ReverseProxy do
* `req_headers`, `resp_headers` additional headers.
* `req_headers`, `resp_headers` additional headers.
- * `http`: options for [gun](https://github.com/ninenines/gun).
+ * `http`: options for [
hackney](https://github.com/benoitc/hackney) or [
gun](https://github.com/ninenines/gun).
"""
@default_options [pool: :media]
"""
@default_options [pool: :media]