Skip to main content

Module server

Module server 

Source
Expand description

Thunder RPC server — the one listener every family server derives from.

Products integrate by implementing Dispatch (SRV-020) and calling spawn_listener with their Config; everything else is Thunder’s:

  • lifecycle — accept loop, per-connection writer task, graceful drain, per-connection failure isolation (SRV-001..005);
  • the Synap-derived hot path — BufWriter + drain-then-flush, exactly one serialization per response, TCP_NODELAY, per-read idle timeout (SRV-006..009);
  • sessions and profile enforcement — lock-free auth flag, handshake gating, Thunder-built HELLO replies, PUSH_ID policy (SRV-010..014, PRO-030/031);
  • plain-atomic metrics recorded after successful writes (SRV-030).

Contract: docs/specs/SPEC-004-server.md. TLS (SRV-040) is pending the T0 family decision and is intentionally not wired yet.

Structs§

ListenerConfig
Listener configuration. Family posture keeps binds loopback/private by default (SRV-040 guidance).
ListenerHandle
Handle to a running listener (SRV-001).
MetricsSnapshot
One consistent-enough read of the listener’s counters (SRV-030), exporter-agnostic by design.
Principal
The identity a successful Dispatch::authenticate resolves to. Stored on the Session and fed to Dispatch::capabilities for the HELLO reply (SRV-014).
PushClosed
The connection behind a PushSender is gone; the frame was dropped.
PushSender
Typed, clonable handle for server-initiated push frames (SRV-013).
ServerInfo
Server identity used by Thunder-built HELLO replies (SRV-014).
Session
Session state shared between the read loop and every dispatch task (SRV-010): the auth flag is a lock-free atomic flipped by HELLO/AUTH and read by the dispatch path without locks.

Enums§

AuthError
Authentication failure from the product hook (SRV-012). Thunder maps it to the profile’s error convention before it reaches the wire (SRV-021).
Credentials
Credentials parsed by Thunder from HELLO/AUTH payloads (SRV-012).

Constants§

NOAUTH
Family-pinned auth-required error (Resp3Prefixes, SRV-011).
NOPERM
Family-pinned insufficient-privilege error (Resp3Prefixes).
WRONGPASS
Family-pinned bad-credentials error (Resp3Prefixes).

Traits§

Dispatch
Product integration is exactly this trait (SRV-020).

Functions§

format_bracket_code
Format the machine-readable convention: "[<code>] <message>" (PRO-014 BracketCode).
format_err
Format the generic-error convention: "ERR <message>" (PRO-014 Resp3Prefixes).
spawn_listener
Bind config.addr and run the accept loop: one task per connection, graceful shutdown through the returned handle (SRV-001).