Seven HB_FUNCs that fivenode's bridge_*.prg layer relies on: _CTX_SET_JSON / _CTX_GET_JSON — per-request context payload _OUT_APPEND / _OUT_GET / _OUT_CLEAR — response body buffer _BRIDGE_SET_RESULT / _BRIDGE_GET_RESULT — fast-path response Crucially per-thread, not process-global like the original C implementation. fivenode runs single-threaded under N-API so a static buffer per process was fine; fivenode_go runs one *hbrt.Thread per HTTP request goroutine, so the state is keyed by *hbrt.Thread in a sync.Map. The HTTP dispatcher will call CleanupThread once per request to keep the map bounded (sub-phase 1a.3-3). Also exposes Go-side helpers (OutputBytes, Result, SetContextJSON, CleanupThread) so the dispatcher can seed the context and harvest the response without bouncing back through PRG. Verified with app/capi_test.prg: all seven functions behave as expected; combined with the Five hb_jsonDecode byref fix, ctx_get() now correctly returns hash values rather than the fallback default. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
9.0 KiB
9.0 KiB