code wiki / _hdl_build / nx_apm_mock.nx
nx_apm_mock.nx
buildroot/runtime/_hdl_build/nx_apm_mock.nx
about
nx_apm_mock.nx -- SOVEREIGN controllable mock HTTP daemon for gating the internal APM collector.
WHY: the collector (nx_apm_collect) must be PROVEN to (a) measure low latency on a healthy daemon,
(b) detect a daemon that SERIALIZES + wedges under concurrent load (the live :8791 reader symptom),
(c) survive a daemon that is slower than the probe timeout (graceful degradation, no infinite hang),
and (d) NOT report a DOWN daemon as healthy (liar-kill). This mock provides all four conditions
deterministically without touching any real daemon.
It is SINGLE-THREADED-SERIAL on purpose: it accepts one connection at a time, optionally sleeps
`delay_ms`, then responds 200 + closes. Under N concurrent connects the Nth client therefore waits
~N*delay_ms -- exactly the serialization-amplification that makes "tabs don't load". It serves
`max_reqs` requests then exits (SELF-TERMINATING -> the gate needs no kill primitive; it just reaps).
usage: nx_apm_mock <port> <delay_ms> <max_reqs> (binds 127.0.0.1 only -- never LAN-exposed)
license_tier: ORIGINAL
dependencies 1 imports · 0 importers
imports: nx_syscalls.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 17 | const AMK_MAGIC_4096: i64 = 4096 |
| 18 | const AMK_MAGIC_18099: i64 = 18099 |
| 19 | const AMK_MAGIC_1000000: i64 = 1000000 |
| 21 | const AMK_RESP: *u8 = "HTTP/1.1 200 OK\r\nContent-Length: 2\r\nConnection: close\r\n\r\nok" |
functions
| 23 | func amk_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } called by 1: apm_mock_listen |
| 26 | func amk_atoi(s: *u8) -> i64 called by 1: main |
| 33 | func amk_addr(out: *u8, a: i64, b: i64, c: i64, d: i64, port: i64) -> i64 called by 1: apm_mock_listen |
| 46 | func apm_mock_listen(port: i64, delay_ms: i64, hold_ms: i64, max_reqs: i64) -> i64 |
| 72 | func main(argc: i64, argv: *i64) -> i64 |