macula_mesh_client (macula v3.13.0)
View SourceMacula Mesh Client — connects a node to the relay mesh via QUIC.
Single gen_server managing ONE persistent QUIC connection to a relay with automatic failover across multiple relays. On disconnect, cycles to the next relay in the list with exponential backoff + jitter. Replays all subscriptions and procedure registrations on reconnect.
This is the SDK client module. It speaks the node role only — it cannot identify as a relay, cannot subscribe to _swim/_dht/_relay.*, and has no loop-prevention concerns. For relay-to-relay peering connections, see macula_peer_client in the macula-relay repository.
Usage:
{ok, Client} = macula_mesh_client:start_link(#{
relays => [<<"quic://boot.macula.io:443">>],
realm => <<"io.macula">>
}).
Summary
Functions
Advertise a streaming procedure (default mode: server_stream). Registers locally in this client's stream_procedures map AND sends a register_procedure frame upstream so the relay routes incoming STREAM_OPEN frames for Procedure back to this client.
Open a server-stream call against a connected mesh client.
Open a client-stream or bidi call (mode from opts; default bidi).
Send a STREAM_* frame out the QUIC stream (called by macula_stream_v1 processes when their peer shape is {remote, ...}).
Types
Functions
-spec advertise_stream(pid(), binary(), stream_handler()) -> ok | {error, term()}.
Advertise a streaming procedure (default mode: server_stream). Registers locally in this client's stream_procedures map AND sends a register_procedure frame upstream so the relay routes incoming STREAM_OPEN frames for Procedure back to this client.
-spec advertise_stream(pid(), binary(), stream_mode(), stream_handler()) -> ok | {error, term()}.
Open a server-stream call against a connected mesh client.
Open a client-stream or bidi call (mode from opts; default bidi).
Send a STREAM_* frame out the QUIC stream (called by macula_stream_v1 processes when their peer shape is {remote, ...}).
-spec stop(pid()) -> ok.