Skip to main content

Module server

Module server 

Source

Structs§

ServerAuth
Authentication material and DoS bounds applied before a TCP connection may reach the frame router.

Enums§

ConnectionError
ServerError

Constants§

CONNECTION_EGRESS_BYTE_BUDGET
Bytes (envelope header plus body) one connection’s egress queue may hold before a module-to-client enqueue must wait for room.
CONNECTION_EGRESS_FRAME_CAP
Frame-count backstop for the same queue (the tokio channel’s capacity). The byte budget is the real bound; this one only matters for floods of tiny or empty frames, which cost bookkeeping per frame rather than bytes. 32,768 frames times 128 bytes is exactly the 4 MiB budget, so for any mean frame of 128 bytes or more the byte budget binds first; below that (for example 21-byte empty frames, of which 4 MiB would be almost 200,000) the count does. The channel allocates slots lazily, so a large capacity costs nothing until it is used.
CONNECTION_EGRESS_STALL_GRACE
Let a reading client drain a short fanout burst, but never park a module’s frame reader for more than 250 ms. The atomic backlog age is measured from the enqueue time of the frame the writer is on, or of the frame that made the queue non-empty. A blocked writer makes that age the stopped-reader signal; between frames it may be one frame older than the true head, which is acceptable for this bounded grace and avoids a lock on every frame.
DEFAULT_AUTH_DEADLINE
DEFAULT_MAX_UNAUTHENTICATED_CONNECTIONS
MAX_PENDING_ROUTE_OPENS_PER_CONNECTION
A pending route.open holds one reserved slot in the connection’s egress queue until its module answers, and its response is sent outside the byte budget. Eight concurrent opens per connection keep a reconnect burst parallel while bounding both the reserved slots and the bytes that bypass the budget.

Functions§

handle_connection
Run the authenticated frame read -> route loop for one connection.
serve_listener
Serve an already-bound TCP listener. Each accepted connection gets its own async task so concurrent clients do not block the accept loop.
serve_listeners
Serve all already-bound loopback TCP listeners until one accept loop fails.