1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Gun do
6 @callback open(charlist(), pos_integer(), map()) :: {:ok, pid()}
7 @callback info(pid()) :: map()
8 @callback close(pid()) :: :ok
9 @callback await_up(pid, pos_integer()) :: {:ok, atom()} | {:error, atom()}
10 @callback connect(pid(), map()) :: reference()
11 @callback await(pid(), reference()) :: {:response, :fin, 200, []}
12 @callback set_owner(pid(), pid()) :: :ok
14 defp api, do: Pleroma.Config.get([Pleroma.Gun], Pleroma.Gun.API)
16 def open(host, port, opts), do: api().open(host, port, opts)
18 def info(pid), do: api().info(pid)
20 def close(pid), do: api().close(pid)
22 def await_up(pid, timeout \\ 5_000), do: api().await_up(pid, timeout)
24 def connect(pid, opts), do: api().connect(pid, opts)
26 def await(pid, ref), do: api().await(pid, ref)
28 def set_owner(pid, owner), do: api().set_owner(pid, owner)