X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fgun%2Fgun.ex;h=4043e488047a0716db3fa6f1b2250e529fe30106;hb=cf2a0574e77ed207453215ae83377a3eb8f2fa0c;hp=4a1bbc95f6f9156dd4e39c52a5c6d22da59d24a3;hpb=13918cb545d583decfb728300850b307c59e2031;p=akkoma
diff --git a/lib/pleroma/gun/gun.ex b/lib/pleroma/gun/gun.ex
index 4a1bbc95f..4043e4880 100644
--- a/lib/pleroma/gun/gun.ex
+++ b/lib/pleroma/gun/gun.ex
@@ -1,45 +1,31 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2019 Pleroma Authors
+# Copyright © 2017-2020 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Gun do
- @behaviour Pleroma.Gun.API
+ @callback open(charlist(), pos_integer(), map()) :: {:ok, pid()}
+ @callback info(pid()) :: map()
+ @callback close(pid()) :: :ok
+ @callback await_up(pid, pos_integer()) :: {:ok, atom()} | {:error, atom()}
+ @callback connect(pid(), map()) :: reference()
+ @callback await(pid(), reference()) :: {:response, :fin, 200, []}
+ @callback set_owner(pid(), pid()) :: :ok
- alias Pleroma.Gun.API
+ @api Pleroma.Config.get([Pleroma.Gun], Pleroma.Gun.API)
- @gun_keys [
- :connect_timeout,
- :http_opts,
- :http2_opts,
- :protocols,
- :retry,
- :retry_timeout,
- :trace,
- :transport,
- :tls_opts,
- :tcp_opts,
- :socks_opts,
- :ws_opts
- ]
+ defp api, do: @api
- @impl API
- def open(host, port, opts \\ %{}), do: :gun.open(host, port, Map.take(opts, @gun_keys))
+ def open(host, port, opts), do: api().open(host, port, opts)
- @impl API
- defdelegate info(pid), to: :gun
+ def info(pid), do: api().info(pid)
- @impl API
- defdelegate close(pid), to: :gun
+ def close(pid), do: api().close(pid)
- @impl API
- defdelegate await_up(pid), to: :gun
+ def await_up(pid, timeout \\ 5_000), do: api().await_up(pid, timeout)
- @impl API
- defdelegate connect(pid, opts), to: :gun
+ def connect(pid, opts), do: api().connect(pid, opts)
- @impl API
- defdelegate await(pid, ref), to: :gun
+ def await(pid, ref), do: api().await(pid, ref)
- @spec flush(pid() | reference()) :: :ok
- defdelegate flush(pid), to: :gun
+ def set_owner(pid, owner), do: api().set_owner(pid, owner)
end