Expand description
mongreldb-server — a long-lived process holding a multi-table Database
open, serving SQL + table-qualified native APIs over HTTP.
Endpoints: GET /health → 200 OK GET /tables → [“t1”, “t2”, …] POST /tables → create table DELETE /tables/{name} → drop table POST /tables/{name}/put → upsert one row POST /tables/{name}/count → { “count”: N } POST /tables/{name}/commit → { “epoch”: N } POST /sql → Arrow IPC bytes POST /txn → atomic cross-table transaction
Usage: mongreldb-server <db_dir> [port]
Structs§
- Session
Store - Token-keyed pool of live sessions. Threaded through
AppStateasArc<SessionStore>so the idle reaper (a detached thread) shares the same map as request handlers.
Functions§
- build_
app - build_
app_ full - Build the daemon router with full auth configuration including user-based auth. Sessions are enabled with a default capacity (256) and idle timeout (300 s).
- build_
app_ with_ config - Build the daemon router with optional auth token and max-connections limit.
- build_
app_ with_ external_ modules - build_
app_ with_ sessions - Build the daemon router with an explicit, externally-owned session store.
The caller (typically
main) keeps theArc<SessionStore>so it can spawn the idle reaper against the same map the handlers use. - spawn_
auto_ compactor - Launch the §5.9 background auto-compaction sweep (run-count cost trigger).
One OS thread, sleeping
intervalbetween sweeps; each tick locks each table individually and callsTable::maybe_compact. Best-effort: a compaction error is logged and never aborts the sweep. - spawn_
session_ reaper - Background idle-session reaper. Sweeps every 30 s, evicting sessions whose
last_usedexceeds the configured timeout. Errors are logged and never abort the sweep. Mirrorsspawn_auto_compactor’s pattern.