66e0d056892ccc55dbb8d5a2b249b38f60dd552b
[akkoma] / lib / pleroma / http / connection.ex
1 defmodule Pleroma.HTTP.Connection do
2 @moduledoc """
3 Connection for http-requests.
4 """
5
6 @hackney_options [
7 pool: :default,
8 timeout: 10000,
9 recv_timeout: 20000
10 ]
11 @adapter Application.get_env(:tesla, :adapter)
12
13 @doc """
14 Configure a client connection
15
16 # Returns
17
18 Tesla.Env.client
19 """
20 @spec new(Keyword.t()) :: Tesla.Env.client()
21 def new(opts \\ []) do
22 Tesla.client([], {@adapter, hackney_options(opts)})
23 end
24
25 # fetch Hackney options
26 #
27 defp hackney_options(opts \\ []) do
28 options = Keyword.get(opts, :adapter, [])
29 @hackney_options ++ options
30 end
31 end