summaryrefslogtreecommitdiff
path: root/lib/pleroma/gun/api/gun.ex
blob: 603dd700e74dede15aca64fff5867db0b34827eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Pleroma: A lightweight social networking server
# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.Gun.API.Gun do
  @behaviour Pleroma.Gun.API

  alias Pleroma.Gun.API

  @gun_keys [
    :connect_timeout,
    :http_opts,
    :http2_opts,
    :protocols,
    :retry,
    :retry_timeout,
    :trace,
    :transport,
    :tls_opts,
    :tcp_opts,
    :ws_opts
  ]

  @impl API
  def open(host, port, opts) do
    :gun.open(host, port, Map.take(opts, @gun_keys))
  end

  @impl API
  def info(pid), do: :gun.info(pid)

  @impl API
  def close(pid), do: :gun.close(pid)

  @impl API
  def await_up(pid), do: :gun.await_up(pid)

  @impl API
  def connect(pid, opts), do: :gun.connect(pid, opts)

  @impl API
  def await(pid, ref), do: :gun.await(pid, ref)
end