Expand description
Process-wide, opt-in HTTP capture sink for dev tooling.
The scripting HTTP layer (lumen-script’s fetch() / http()
builtins) unconditionally reports request/response lifecycle events to
record. When no sink has been installed - the default in a release
build, and always when lumen-devtools is not compiled in - record
is a single atomic load plus branch and drops the event on the floor, so
there is zero capture cost and no unbounded buffer growth.
A dev-only consumer (the devtools Network tab) calls init_net_capture
once at startup to install the sink, then drains accumulated events each
tick via drain into its own bounded ring. This mirrors the
crate::signals external-mutation channel pattern: one global
OnceLock sender, one OnceLock<Mutex<Receiver>>, both idempotent.
Enums§
- NetEvent
- One HTTP lifecycle event emitted by the scripting fetch/http layer.
Functions§
- drain
- Drain up to
maxpending events (oldest first). Returns empty when the sink was never installed or nothing is queued. - init_
net_ capture - Idempotently install the capture sink. Safe to call multiple times; only
the first call creates the channel. After this returns,
recordstarts forwarding events fordrainto collect. - record
- Report an HTTP lifecycle event. No-op (one atomic load + branch) until
init_net_capturehas run, so release builds without dev tooling pay nothing and never accumulate an unbounded buffer.