macula_gateway_quic_server (macula v0.20.3)

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 synchronous calls. Set gateway PID for message routing

Handle asynchronous casts.

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

Initialize the QUIC server and start QUIC listener.

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

Start the QUIC server gen_server.

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.

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.