Search documentation of macula

# macula_gateway_quic_server (macula v0.44.2)

View Source

QUIC Transport Layer Gen_Server

Handles all QUIC transport operations for the gateway: - Owns QUIC listener - Receives {quic, ...} events - Decodes protocol messages - Routes messages to gateway for business logic

This separation follows proper OTP design: - One process, one responsibility (transport vs routing) - Clean fault isolation (QUIC crashes don't crash gateway) - Proper supervision (supervisor can restart independently) - Testability (can test transport in isolation)

# Summary

## Functions

handle_call(Request, From, State)

Handle synchronous calls. Set gateway PID for message routing

handle_cast(Msg, State)

Handle asynchronous casts.

handle_info(Info, State)

Handle QUIC event: new_stream (stream created by peer). Associates the stream with its parent connection to enable peer address lookup.

init(Opts)

Initialize the QUIC server and start QUIC listener.

set_gateway(QuicServerPid, GatewayPid)

Set the gateway PID for message routing. Called by supervisor after both quic_server and gateway have started.

shield_metrics()

Returns shield metrics: recent connections with IPs, timestamps, and status. Reads directly from named ETS tables. No gen_server call needed. Returns empty metrics if the QUIC server has not started yet.

start_link(Opts)

Start the QUIC server gen_server.

terminate(Reason, State)

Cleanup on termination.

# Functions

# handle_call(Request, From, State)

Handle synchronous calls. Set gateway PID for message routing

# handle_cast(Msg, State)

Handle asynchronous casts.

# handle_info(Info, State)

Handle QUIC event: new_stream (stream created by peer). Associates the stream with its parent connection to enable peer address lookup.

# init(Opts)

Initialize the QUIC server and start QUIC listener.

# set_gateway(QuicServerPid, GatewayPid)

    -spec set_gateway(pid(), pid()) -> ok.

Set the gateway PID for message routing. Called by supervisor after both quic_server and gateway have started.

# shield_metrics()

    -spec shield_metrics() -> map().

Returns shield metrics: recent connections with IPs, timestamps, and status. Reads directly from named ETS tables. No gen_server call needed. Returns empty metrics if the QUIC server has not started yet.

# start_link(Opts)

    -spec start_link(Opts :: proplists:proplist()) -> {ok, pid()} | {error, term()}.

Start the QUIC server gen_server.

# terminate(Reason, State)

Cleanup on termination.