nquic_listener_mgr (nquic v1.0.0)
View SourceListener manager gen_server.
Holds the mutable state that used to live inside the legacy nquic_listener
gen_server: the accept queue, the parked acceptors, the configured listen
options, and the resolved UDP port. Publishes its own pid to the listener's
dispatch table on init so receivers and connections can route the
connection_established notification through nquic_dispatch:get_mgr/1.
Started as the first child of nquic_listener_sup under a rest_for_one
strategy, so a crash here cascades into a fresh sub-tree below
(partitions, receivers) instead of leaving stale
references in the dispatch table.
Summary
Functions
Accept a new connection, blocking until one is available or timeout expires.
Hand a freshly handshaked, proactively exported connection to the
listener manager. The handshake gen_statem has already terminated;
Entry carries the protocol state, socket, dispatch handle, and the
per-conn-fd flag.
Return the dispatch table for this listener.
Return the metrics handle attached to this listener's dispatch table.
Return the UDP port number this listener is bound to.
Return the listener's static stateless-reset key.
Return a single listener option as seen at startup.
Start the listener manager. Args carries the dispatch handle and resolved opts.
Types
-type accept_entry() :: {exported, nquic_protocol:state(), nquic_socket:t(), nquic_dispatch:t() | undefined, boolean(), pid()}.
Functions
-spec accept(pid(), timeout()) -> {ok, accept_entry()} | {error, nquic_error:any_reason()}.
Accept a new connection, blocking until one is available or timeout expires.
-spec connection_established(pid(), accept_entry()) -> ok.
Hand a freshly handshaked, proactively exported connection to the
listener manager. The handshake gen_statem has already terminated;
Entry carries the protocol state, socket, dispatch handle, and the
per-conn-fd flag.
-spec get_dispatch(pid()) -> {ok, nquic_dispatch:t()} | {error, nquic_error:any_reason()}.
Return the dispatch table for this listener.
-spec get_metrics(pid()) -> {ok, nquic_metrics:t()} | {error, nquic_error:any_reason()}.
Return the metrics handle attached to this listener's dispatch table.
-spec get_port(pid()) -> {ok, inet:port_number()} | {error, nquic_error:any_reason()}.
Return the UDP port number this listener is bound to.
-spec get_static_key(pid()) -> {ok, binary()} | {error, nquic_error:any_reason()}.
Return the listener's static stateless-reset key.
-spec handle_call(term(), gen_server:from(), #state{dispatch :: nquic_dispatch:t(), opts :: map(), port :: inet:port_number(), static_key :: binary(), accept_queue :: queue:queue(accept_entry()), waiting_acceptors :: [gen_server:from()], max_accept_queue :: non_neg_integer()}) -> {reply, term(), #state{dispatch :: nquic_dispatch:t(), opts :: map(), port :: inet:port_number(), static_key :: binary(), accept_queue :: queue:queue(accept_entry()), waiting_acceptors :: [gen_server:from()], max_accept_queue :: non_neg_integer()}} | {noreply, #state{dispatch :: nquic_dispatch:t(), opts :: map(), port :: inet:port_number(), static_key :: binary(), accept_queue :: queue:queue(accept_entry()), waiting_acceptors :: [gen_server:from()], max_accept_queue :: non_neg_integer()}}.
-spec handle_cast(term(), #state{dispatch :: nquic_dispatch:t(), opts :: map(), port :: inet:port_number(), static_key :: binary(), accept_queue :: queue:queue(accept_entry()), waiting_acceptors :: [gen_server:from()], max_accept_queue :: non_neg_integer()}) -> {noreply, #state{dispatch :: nquic_dispatch:t(), opts :: map(), port :: inet:port_number(), static_key :: binary(), accept_queue :: queue:queue(accept_entry()), waiting_acceptors :: [gen_server:from()], max_accept_queue :: non_neg_integer()}}.
-spec handle_info(term(), #state{dispatch :: nquic_dispatch:t(), opts :: map(), port :: inet:port_number(), static_key :: binary(), accept_queue :: queue:queue(accept_entry()), waiting_acceptors :: [gen_server:from()], max_accept_queue :: non_neg_integer()}) -> {noreply, #state{dispatch :: nquic_dispatch:t(), opts :: map(), port :: inet:port_number(), static_key :: binary(), accept_queue :: queue:queue(accept_entry()), waiting_acceptors :: [gen_server:from()], max_accept_queue :: non_neg_integer()}}.
-spec init(map()) -> {ok, #state{dispatch :: nquic_dispatch:t(), opts :: map(), port :: inet:port_number(), static_key :: binary(), accept_queue :: queue:queue(accept_entry()), waiting_acceptors :: [gen_server:from()], max_accept_queue :: non_neg_integer()}} | {stop, term()}.
-spec opt(pid(), atom()) -> {ok, term()} | {error, nquic_error:any_reason()}.
Return a single listener option as seen at startup.
-spec start_link(#{dispatch := nquic_dispatch:t(), opts := map()}) -> {ok, pid()} | ignore | {error, term()}.
Start the listener manager. Args carries the dispatch handle and resolved opts.
-spec terminate(term(), #state{dispatch :: nquic_dispatch:t(), opts :: map(), port :: inet:port_number(), static_key :: binary(), accept_queue :: queue:queue(accept_entry()), waiting_acceptors :: [gen_server:from()], max_accept_queue :: non_neg_integer()}) -> ok.