macula_peering (macula v3.13.0)
View SourceMacula peering — connection state machine API.
Each peer connection is one macula_peering_conn gen_statem under the macula_peering_conn_sup simple_one_for_one supervisor.
Two entry points:
connect/1— outbound dial; worker drives the QUIC connect.accept/2— inbound; caller transfers ownership of an already-establishedmacula_quicconnection (areference()) to a new worker.
The caller passes a controlling_pid in opts; that pid receives peering events as messages:
{macula_peering, connected, ConnPid, PeerNodeId}{macula_peering, frame, ConnPid, Frame}(post-handshake){macula_peering, disconnected, ConnPid, Reason}
Summary
Functions
Inbound accept. Caller currently owns Conn (e.g. it's the listener owner that just received {quic, new_conn, Conn, _}). The transfer of ownership and the handshake start are sequenced atomically.
Initiate a graceful close (sends GOODBYE, drains 5s, terminates).
Outbound connect. Spawns a worker that opens a QUIC connection to target and runs the CONNECT/HELLO handshake.
Send a frame through the peer connection. Signs the frame with the local identity if it isn't already signed. Fire-and-forget.
Types
-type opts() :: macula_peering_conn:opts().
Functions
Inbound accept. Caller currently owns Conn (e.g. it's the listener owner that just received {quic, new_conn, Conn, _}). The transfer of ownership and the handshake start are sequenced atomically.
-spec close(pid()) -> ok.
Initiate a graceful close (sends GOODBYE, drains 5s, terminates).
Outbound connect. Spawns a worker that opens a QUIC connection to target and runs the CONNECT/HELLO handshake.
-spec send_frame(pid(), macula_frame:frame()) -> ok.
Send a frame through the peer connection. Signs the frame with the local identity if it isn't already signed. Fire-and-forget.