akkoma/lib/pleroma/gun/gun.ex
Alexander Strizhakov 514c899275
adding gun adapter
2020-02-18 08:19:01 +03:00

45 lines
888 B
Elixir

# Pleroma: A lightweight social networking server
# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.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,
:socks_opts,
:ws_opts
]
@impl API
def open(host, port, opts \\ %{}), do: :gun.open(host, port, Map.take(opts, @gun_keys))
@impl API
defdelegate info(pid), to: :gun
@impl API
defdelegate close(pid), to: :gun
@impl API
defdelegate await_up(pid), to: :gun
@impl API
defdelegate connect(pid, opts), to: :gun
@impl API
defdelegate await(pid, ref), to: :gun
@spec flush(pid() | reference()) :: :ok
defdelegate flush(pid), to: :gun
end