Libp2p.ReqRespServer (libp2p_elixir v0.9.0)

Minimal concurrency gating for Req/Resp handlers.

Ethereum's p2p-interface requires limiting concurrent requests per protocol ID. This module provides a reusable mechanism that libp2p stream handlers can call.

Summary

Functions

Returns a specification to start this module under a supervisor.

Types

key()

@type key() :: {binary(), binary()} | binary()

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

handle(server, key, request_bytes, handler_fun, opts \\ [])

@spec handle(pid() | atom(), key(), binary(), (binary() -> binary()), keyword()) ::
  {:ok, binary()} | {:error, term()}

start_link(opts)

@spec start_link(keyword()) :: GenServer.on_start()