macula_stream_local (macula v3.13.0)

View Source

Local registry + dispatcher for streaming RPC.

Phase 1 of PLAN_MACULA_STREAMING.md ships LOCAL streaming only — the client-side and server-side macula_stream processes both live in the same BEAM and are paired with macula_stream_v1:pair/2. This module is the registry that lets call_stream find a locally- advertised handler for a given procedure name.

Phase 2 will add a parallel path through macula_mesh_client that bridges streams to QUIC. The public SDK surface in macula.erl stays the same; macula_stream_local becomes a fast in-process short-circuit for procedures advertised on the same node.

Summary

Functions

Advertise a streaming procedure (default mode: server_stream).

Open a server-stream call. Returns the client-side stream pid. The caller drains chunks with macula_stream_v1:recv/2.

Open a client-stream or bidi call. Returns the client-side stream pid; caller writes with macula_stream_v1:send/2,3 and reads the terminal value with macula_stream_v1:await_reply/1,2.

Types

handler/0

-type handler() :: fun((Stream :: pid(), Args :: term()) -> any()).

mode/0

-type mode() :: macula_stream_v1:mode().

Functions

advertise(Procedure, Handler)

-spec advertise(binary(), handler()) -> ok | {error, term()}.

Advertise a streaming procedure (default mode: server_stream).

advertise(Procedure, Mode, Handler)

-spec advertise(binary(), mode(), handler()) -> ok | {error, term()}.

call_stream(Procedure, Args, Opts)

-spec call_stream(binary(), term(), map()) -> {ok, pid()} | {error, term()}.

Open a server-stream call. Returns the client-side stream pid. The caller drains chunks with macula_stream_v1:recv/2.

handle_call(Msg, From, State)

handle_cast(Msg, State)

handle_info(Msg, State)

init(_)

list_advertised()

-spec list_advertised() -> [{binary(), mode()}].

open_stream(Procedure, Args, Opts)

-spec open_stream(binary(), term(), map()) -> {ok, pid()} | {error, term()}.

Open a client-stream or bidi call. Returns the client-side stream pid; caller writes with macula_stream_v1:send/2,3 and reads the terminal value with macula_stream_v1:await_reply/1,2.

start_link()

-spec start_link() -> {ok, pid()} | {error, term()}.

terminate(Reason, State)

unadvertise(Procedure)

-spec unadvertise(binary()) -> ok.