API Reference portals v#0.1.0

Copy Markdown View Source

Modules

Public API for invoking functions in a supervised external-language worker (FR-2).

Introspection helper for code running inside a callback handler (invoked by Portals.Connection in response to a worker's CALLBACK frame). See protocol/v1.md section 8 for the reentrancy-depth model.

Behaviour implemented by every wire codec (Portals.Codec.MessagePack in production, Portals.Codec.ETFBench for internal benchmarking only).

Explicit wrapper marking a value as the MessagePack bin type rather than str. Plain Elixir binaries encode as UTF-8 strings by default; wrap arbitrary byte payloads (image data, serialized blobs, and other non-text binaries) in %Portals.Codec.Bin{} to force bin encoding.

The mandatory, portable 1.0 wire codec: MessagePack core types plus the Portals Erlang-value extensions from Portals.TermExtensions.

Black-box protocol conformance runner (FR-7 / Phase 1 exit criteria).

The protocol conformance suite every worker SDK must pass.

The shared black-box integration suite every worker SDK must pass.

Owns one worker's socket, protocol state machine, and in-flight request table (FR-1, FR-2). One Portals.Connection GenServer corresponds to one launched worker process.

The single failure representation returned to every Portals caller (FR-4). All non-{:ok, value} outcomes are {:error, %Portals.Error{}}.

The BEAM-side callback target the shared conformance suites call back into (as Elixir.Portals.Fixtures.CallbackTarget) from every SDK's bench_worker fixture.

Exact-version handshake rules shared by every SDK.

Decoded HELLO fields.

A supervised, load-balanced set of workers running the same command (FR-3). Maintains size base workers plus up to max_overflow temporary overflow workers, created on demand and retired as soon as they go idle.

Portals wire protocol v1: frame tags, default limits, and the frame validation rules shared by every SDK implementation.

A reference to one in-flight or completed asynchronous call, returned by Portals.async/5 (or Portals.Connection.async/5). Pass it to Portals.await/2 and Portals.cancel/1.

The contract every portals_<language> package implements.

Private per-worker runtime directory and Unix-domain socket path management (FR-1). Every worker gets its own 0700 directory beneath a shared Portals runtime root; stale sockets are removed deterministically before a new listener binds to the same path.

A handle on one bidirectional stream, plus the demand/credit and terminal-state machine behind it (FR-5, Phase 6).

The per-stream credit and terminal-state machine, owned functionally by Portals.Connection (like the pending-request table) rather than by a process of its own.

Erlang-specific value extensions layered on top of core MessagePack.

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.

Length-framed stdin/stdout fallback transport, used automatically only on platforms where Unix-domain sockets are unsupported. Experimental: Linux (the only officially supported 1.0 platform) always uses Portals.Transport.Unix.

Default transport: one BEAM-created Unix-domain socket per worker.

Launches and monitors the direct worker process through a BEAM Port (FR-1). Owns only the direct child process — descendant processes the worker itself spawns are not tracked or reaped; applications that need process-tree ownership must wrap the worker in a container or process group of their own.

Mix Tasks

Prints the absolute path of the worker SDK bundled with a language package, for configuring editors, type checkers, go.mod replace directives or javac -cp