quic_server_registry (quic v1.3.1)

View Source

ETS-based registry for named QUIC server lookup.

This module provides a registry for named QUIC servers, allowing lookup of server information by name. The registry monitors server processes and automatically removes them when they terminate.

Usage

   %% Register a server
   ok = quic_server_registry:register(my_server, Pid, 4433, Opts).
  
   %% Look up a server
   {ok, #{pid := Pid, port := 4433}} = quic_server_registry:lookup(my_server).
  
   %% List all servers
   [my_server] = quic_server_registry:list().

Summary

Functions

Get the connection PIDs for a named server.

Get the port for a named server. If the server was started with port 0, queries the actual bound port from a listener and updates the registry for future lookups.

List all registered server names.

Look up a server by name.

Register a named server.

Start the server registry.

Unregister a named server.

Update the port for a named server. Used when a server was started with port 0 and we've discovered the actual port.

Functions

get_connections(Name)

-spec get_connections(atom()) -> {ok, [pid()]} | {error, not_found}.

Get the connection PIDs for a named server.

get_port(Name)

-spec get_port(atom()) -> {ok, inet:port_number()} | {error, not_found}.

Get the port for a named server. If the server was started with port 0, queries the actual bound port from a listener and updates the registry for future lookups.

handle_call(Request, From, State)

handle_cast(Msg, State)

handle_info(Info, State)

init(_)

list()

-spec list() -> [atom()].

List all registered server names.

lookup(Name)

-spec lookup(atom()) -> {ok, map()} | {error, not_found}.

Look up a server by name.

register(Name, Pid, Port, Opts)

-spec register(atom(), pid(), inet:port_number(), map()) -> ok.

Register a named server.

start_link()

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

Start the server registry.

terminate(Reason, State)

unregister(Name)

-spec unregister(atom()) -> ok.

Unregister a named server.

update_port(Name, Port)

-spec update_port(atom(), inet:port_number()) -> ok | {error, not_found}.

Update the port for a named server. Used when a server was started with port 0 and we've discovered the actual port.