macula_stream_v1 (macula v3.13.0)
View SourceMacula streaming RPC — single-stream state machine.
Owns one streaming RPC's state. Each call_stream, open_stream, or server-side handler invocation gets its own macula_stream gen_server. Phase 1 only supports the LOCAL dispatch path: the client-side and server-side macula_stream processes live in the same BEAM and are paired with pair/2. Phase 2 swaps the local peer for a QUIC stream owned by macula_mesh_client; the public API stays unchanged.
See PLAN_MACULA_STREAMING.md (macula-architecture/plans).
Summary
Functions
Abort the stream with a STREAM_ERROR frame. Both sides close; any pending recv/await_reply waiters receive {error, {Code, Message}}.
Attach a remote (QUIC) peer to this stream. Used by macula_mesh_client to wire a stream to its QUIC-carrier: all deliveries out of this stream will be encoded as STREAM_* frames and sent through Client's relay connection, tagged with StreamId. Deliveries INTO this stream still arrive via the deliver_chunk/end/error/reply casts below — mesh_client decodes the incoming frames and forwards them to the local stream pid it tracks for this StreamId.
Wait for the terminal reply (client-stream / bidi).
Close both sides. Idempotent.
Half-close the write side. Recv side stays open.
Deliver a chunk frame from the peer.
Deliver a STREAM_END frame from the peer.
Deliver a STREAM_ERROR frame from the peer.
Deliver a STREAM_REPLY frame from the peer.
Inspect stream state (debugging).
Pair two stream processes as peers (Phase 1 local dispatch).
Receive the next chunk (blocks indefinitely).
Send a binary chunk on the stream.
Server-side: emit a terminal error as the reply value.
Server-side: emit the terminal reply.
Start a stream gen_server.
Types
-type encoding() :: raw | msgpack.
-type mode() :: server_stream | client_stream | bidi.
-type role() :: client | server.
-type stream_id() :: binary().
Functions
Abort the stream with a STREAM_ERROR frame. Both sides close; any pending recv/await_reply waiters receive {error, {Code, Message}}.
Attach a remote (QUIC) peer to this stream. Used by macula_mesh_client to wire a stream to its QUIC-carrier: all deliveries out of this stream will be encoded as STREAM_* frames and sent through Client's relay connection, tagged with StreamId. Deliveries INTO this stream still arrive via the deliver_chunk/end/error/reply casts below — mesh_client decodes the incoming frames and forwards them to the local stream pid it tracks for this StreamId.
Wait for the terminal reply (client-stream / bidi).
-spec close(pid()) -> ok.
Close both sides. Idempotent.
-spec close_send(pid()) -> ok.
Half-close the write side. Recv side stays open.
Deliver a chunk frame from the peer.
-spec deliver_end(pid(), send | both) -> ok.
Deliver a STREAM_END frame from the peer.
Deliver a STREAM_ERROR frame from the peer.
Deliver a STREAM_REPLY frame from the peer.
Inspect stream state (debugging).
Pair two stream processes as peers (Phase 1 local dispatch).
Receive the next chunk (blocks indefinitely).
Send a binary chunk on the stream.
Server-side: emit a terminal error as the reply value.
Server-side: emit the terminal reply.
Start a stream gen_server.
Required opts: id, role, mode, owner.