Skip to main content

Crate mongreldb_server

Crate mongreldb_server 

Source
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§

SessionStore
Token-keyed pool of live sessions. Threaded through AppState as Arc<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 the Arc<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 interval between sweeps; each tick locks each table individually and calls Table::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_used exceeds the configured timeout. Errors are logged and never abort the sweep. Mirrors spawn_auto_compactor’s pattern.