da82983b1eed79db5c31f163956b4365e9e4571a
[akkoma] / lib / pleroma / gun / gun.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Gun do
6 @behaviour Pleroma.Gun.API
7
8 alias Pleroma.Gun.API
9
10 @gun_keys [
11 :connect_timeout,
12 :http_opts,
13 :http2_opts,
14 :protocols,
15 :retry,
16 :retry_timeout,
17 :trace,
18 :transport,
19 :tls_opts,
20 :tcp_opts,
21 :socks_opts,
22 :ws_opts
23 ]
24
25 @impl API
26 def open(host, port, opts \\ %{}), do: :gun.open(host, port, Map.take(opts, @gun_keys))
27
28 @impl API
29 defdelegate info(pid), to: :gun
30
31 @impl API
32 defdelegate close(pid), to: :gun
33
34 @impl API
35 defdelegate await_up(pid, timeout \\ 5_000), to: :gun
36
37 @impl API
38 defdelegate connect(pid, opts), to: :gun
39
40 @impl API
41 defdelegate await(pid, ref), to: :gun
42
43 @spec flush(pid() | reference()) :: :ok
44 defdelegate flush(pid), to: :gun
45
46 @impl API
47 defdelegate set_owner(pid, owner), to: :gun
48 end