Expand description
UDP load-balancing I/O shell + mio event-loop wiring (issue #1273).
This module is the impure half of the UDP datapath: it owns every
syscall, the buffer copies, the per-flow connected upstream sockets, the
timer arming, the BackendMap/health/metrics edges, and the slab/token
bookkeeping. It drives the pure sans-io core in
crate::protocol::udp (the UdpManager /
UdpFlow two-level split) through ManagerInput / Output.
Architecture (mirrors tcp.rs, but UDP is one-listener-many-flows):
UdpListenerwraps the singlemio::net::UdpSocketa listener binds. There is no accept loop — a readable event means “datagrams waiting”, not “a new connection”.UdpProxyholds the listeners, the per-listenerUdpManagers, the sharedBackendMap, the session slab and the registry. It does not implementProxyConfiguration/L7Proxy(their signatures areTcpStream-bound); the server calls its inherentnotifydirectly.UdpListenerSessionis theProxySessionthe server’s generic readiness path drives. One session backs one listener; itsupdate_readinessdemuxes by token (listener-token = client recv; upstream-token = backend recv). It owns the per-flow connected sockets and theupstream_token -> FlowIdmap.
UDP never goes through accept() / create_session(): a Protocol::UDP
listener readable event falls through Server::ready’s generic arm into
ProxySession::ready.
Long-form lifecycle (datapath, NAT return, teardown, control plane,
hardening): lib/src/protocol/udp/LIFECYCLE.md.
Structs§
- UdpHealth
Checker - Timer-driven, non-blocking UDP backend health prober. Owned by
UdpProxy; driven from the server event loop exactly like the HTTPHealthChecker(pollonce per iteration,ready(token)on owned readiness). - UdpListener
- One UDP listener: a single
mio::net::UdpSocketplus its routing config. Unlike a TCP listener there is no accept loop — a readable event is a batch of datagrams the session drains toWouldBlock. - UdpListener
Session - The
ProxySessionbacking one UDP listener. The server’s generic readiness path drives this (UDP is not in the listen-accept arm). It owns the per-flow connected upstream sockets and demuxes events by token. - UdpProxy
- The UDP proxy. Holds the listeners, one
UdpManagerper listener token, the sharedBackendMap, the session slab and a cloned registry. Does NOT implementProxyConfiguration/L7Proxy; the server drives it through the inherentnotifyplus the activate/give-back helpers.