Libp2p.RequestResponse (libp2p_elixir v0.9.0)

Minimal request-response protocol support.

Summary

Functions

Returns a specification to start this module under a supervisor.

Handle an inbound stream for a registered protocol.

Register a handler for a protocol id.

Perform an outbound request over a connection.

Types

codec()

@type codec() ::
  {encode :: (binary() -> binary()),
   decode :: (binary() -> {:ok, binary(), binary()} | :more)}

proto_id()

@type proto_id() :: binary()

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

handle_inbound(rr, conn, stream_id, proto, initial)

@spec handle_inbound(pid() | atom(), pid(), non_neg_integer(), proto_id(), binary()) ::
  :ok

Handle an inbound stream for a registered protocol.

register(rr, proto, fun)

@spec register(pid() | atom(), proto_id(), (binary(), binary() -> binary())) :: :ok

Register a handler for a protocol id.

request(rr, conn, proto, req_bytes, opts \\ [])

@spec request(pid() | atom(), pid(), proto_id(), binary(), keyword()) ::
  {:ok, binary()} | {:error, term()}

Perform an outbound request over a connection.

start_link(opts \\ [])

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