code wiki / _hdl_build / nx_apistack_ratelimit.nx

nx_apistack_ratelimit.nx

buildroot/runtime/_hdl_build/nx_apistack_ratelimit.nx

2507 B55 linesdepth 3pulls 3 transitivereach 1 importersview sourcekind librarytopic apistack
docsdependenciesstructsconstsfunctions

about

nx_apistack_ratelimit.nx -- CAP-API-RATELIMIT: request quotas over /api (429 on exhaustion). Deterministic token-bucket: refill by (elapsed * rate) capped at cap, then take cost -> pure INTEGER math, so the allow/429 decision is byte-reproducible (the sovereign exceed over cloud rate meters). Quotas are DATA (ratelimits.conf: key<TAB>cap<TAB>rate_per_sec) so a per-shard/per-actor limit is a row, not code. The bucket STATE (tokens, last_refill) is held by the caller (per-key), keeping this a pure, gateable step. license_tier: ORIGINAL

dependencies 2 imports · 1 importers

nx_syscalls.nx nx_site_lock_lib.nx nx_apistack_ratelimit.nx nx_apistack_ratelimit_gate.nx

imports: nx_syscalls.nxnx_site_lock_lib.nx

imported by: nx_apistack_ratelimit_gate.nx

structs

none

consts

8const K_MAGIC_65536: i64 = 65536

functions

11func rl_step(state: *i64, cap: i64, rate: i64, now: i64, cost: i64) -> i64
called by 1: main
23func rl_read_file(path: *u8, out: *u8, cap: i64) -> i64
37func rl_config(conf_path: *u8, key: *u8, key_n: i64, out_cap: *i64, out_rate: *i64) -> i64