macula_connection (macula v0.7.29)

View Source

Macula Connection - QUIC Transport Layer (v0.7.0+).

This module manages the low-level QUIC connection lifecycle and message transport for mesh participants.

Responsibilities: - Establish and maintain QUIC connection - Send messages via QUIC stream - Receive and route incoming messages to handlers - Handle connection errors and reconnection - Message encoding/decoding and buffering

Renamed from macula_connection in v0.7.0 for clarity: - macula_connection = QUIC transport (this module - low-level) - macula_peer = mesh participant (high-level API)

Summary

Functions

decode_messages(Buffer, Acc)

-spec decode_messages(binary(), list()) -> {list(), binary()}.

Decode all complete messages from buffer.

default_config()

-spec default_config() -> map().

get_status(Pid)

-spec get_status(pid()) -> connecting | connected | disconnected | error.

handle_call(Request, From, State)

handle_cast(Msg, State)

handle_info(Info, State)

init(_)

send_message(Pid, Type, Msg)

-spec send_message(pid(), atom(), map()) -> ok | {error, term()}.

start_keepalive_timer(State)

-spec start_keepalive_timer(#state{url :: binary(),
                                   opts :: map(),
                                   node_id :: binary(),
                                   realm :: binary(),
                                   connection :: pid() | undefined,
                                   stream :: pid() | undefined,
                                   status :: connecting | connected | disconnected | error,
                                   recv_buffer :: binary(),
                                   keepalive_timer :: reference() | undefined}) ->
                               #state{url :: binary(),
                                      opts :: map(),
                                      node_id :: binary(),
                                      realm :: binary(),
                                      connection :: pid() | undefined,
                                      stream :: pid() | undefined,
                                      status :: connecting | connected | disconnected | error,
                                      recv_buffer :: binary(),
                                      keepalive_timer :: reference() | undefined}.

Start keep-alive timer if enabled in options.

start_link(Url, Opts)

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

terminate(Reason, State)