macula_connection (macula v0.20.3)
View SourceMacula 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
Make an RPC-style call over a connection. Sends a call message and waits for a reply. Uses the underlying send_message API with type 'bridge_rpc'.
Close a connection gracefully. Stops the gen_server which triggers proper QUIC cleanup in terminate/2. Uses catch expression to handle race conditions where process may already be dead.
Connect to a remote endpoint. Creates a new QUIC connection to the specified host:port.
Decode all complete messages from buffer.
Handle async send message - fire and forget. Sends if connected, logs warning and drops if not.
Send a message over a connection asynchronously. Fire-and-forget delivery - returns immediately.
Send message asynchronously (fire-and-forget). Use for operations where blocking is unacceptable and failures can be tolerated. The message will be sent if connected, silently dropped if not.
Start keep-alive timer if enabled in options.
Functions
Make an RPC-style call over a connection. Sends a call message and waits for a reply. Uses the underlying send_message API with type 'bridge_rpc'.
-spec close(pid()) -> ok.
Close a connection gracefully. Stops the gen_server which triggers proper QUIC cleanup in terminate/2. Uses catch expression to handle race conditions where process may already be dead.
-spec connect(binary(), pos_integer(), map()) -> {ok, pid()} | {error, term()}.
Connect to a remote endpoint. Creates a new QUIC connection to the specified host:port.
Decode all complete messages from buffer.
-spec default_config() -> map().
-spec get_status(pid()) -> connecting | connected | disconnected | error.
Handle async send message - fire and forget. Sends if connected, logs warning and drops if not.
Send a message over a connection asynchronously. Fire-and-forget delivery - returns immediately.
Send message asynchronously (fire-and-forget). Use for operations where blocking is unacceptable and failures can be tolerated. The message will be sent if connected, silently dropped if not.
-spec start_keepalive_timer(#state{url :: binary(), opts :: map(), node_id :: binary(), realm :: binary(), peer_id :: integer(), 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(), peer_id :: integer(), 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.