Portals.Transport behaviour (portals v0.1.0)

Copy Markdown View Source

Transport behaviour for moving framed bytes between the BEAM and a worker. A transport does not know about frame contents; it only owns byte delivery and must deliver received bytes as Erlang messages to the owning process so a Portals.Connection-style GenServer can multiplex transport I/O with call handling in its normal message loop.

Portals.Transport.Unix (default) and Portals.Transport.Stdio (fallback, used automatically on platforms without Unix-domain socket support) both implement this behaviour.

Summary

Callbacks

Block (up to timeout) for the worker to connect.

Stop delivering data to the caller and release transport resources.

Start listening for the worker's single incoming connection.

Send raw bytes.

Types

socket()

@type socket() :: term()

Callbacks

accept(socket, timeout)

@callback accept(socket(), timeout()) :: {:ok, socket()} | {:error, term()}

Block (up to timeout) for the worker to connect.

close(socket)

@callback close(socket()) :: :ok

Stop delivering data to the caller and release transport resources.

listen(opts)

@callback listen(opts :: keyword()) :: {:ok, socket()} | {:error, term()}

Start listening for the worker's single incoming connection.

send(socket, iodata)

@callback send(socket(), iodata()) :: :ok | {:error, term()}

Send raw bytes.