Skip to main content

Crate server

Crate server 

Source

Re-exports§

pub use http::router;
pub use http::router_with_access_keys;
pub use http::router_with_auth;
pub use http::router_with_cors;
pub use http::router_with_ready_flag;
pub use http::router_with_role_tokens;
pub use http::router_with_tx_limits;
pub use http::router_with_ui;
pub use http::router_with_ui_tls;
pub use http::serve_with_role_tokens;
pub use http::serve_with_role_tokens_and_shutdown;
pub use http::serve_with_role_tokens_and_shutdown_with_ready_flag;
pub use http::serve_with_shutdown;
pub use http::serve_with_ui_and_role_tokens;
pub use http::serve_with_ui_and_role_tokens_and_shutdown;
pub use http::serve_with_ui_and_role_tokens_and_shutdown_with_ready_flag;

Structs§

BackupMetrics
The continuous-backup counters GET /metrics reports as mushroomdb_backup_*. The serve loop registers them with register_backup_metrics when backup is configured; without that, no backup series is emitted at all (absent, not zero, so an alert on mushroomdb_backup_lag_seconds cannot be satisfied by a store that was never backed up).
BoltMetrics
The Bolt listener’s counters GET /metrics reports as mushroomdb_bolt_connections_*; absent when Bolt is off.
TxLimits
The limits on open transactions.

Constants§

ASSOCIATION_TOOLS
The tools every store advertises, in the order it lists them.
CORS_ORIGINS_ENV
The environment variable holding the allowed origins.
LOG_TARGET_ROOT
The root this crate’s tracing events are filtered by.
TX_MAX_ENV
Environment variable: most transactions open at once.
TX_MAX_LIFETIME_ENV
Environment variable: seconds a transaction may live, used or not.
TX_TIMEOUT_ENV
Environment variable: seconds a transaction may sit idle.

Functions§

cors_layer_from_env
Read and parse CORS_ORIGINS_ENV from the process environment.
parse_cors_origins
Parse a MUSHROOMDB_CORS_ORIGINS value. Ok(None) for unset/blank.
register_backup_metrics
Report metrics on GET /metrics from now on. Replaces an earlier call.
register_bolt_metrics
Report metrics on GET /metrics from now on. Like register_backup_metrics this is per process: one process serves one store’s metrics.
router
Build the HTTP router over db. The graph read endpoints (/query, /node/{key}, its /edges and /neighborhood), /health, /metrics and /algo/* run on a lock-free ReaderSnapshot, whose capture never waits behind a writer (see SharedDb::reader). /stats, /explain, /suggest, /find_similar and the history routes read the rule engine or the WAL and take the read lock; /ingest takes the write lock. Guards are dropped before any .await. GET /watch upgrades to a WebSocket fed by the post-commit sink.
router_with_access_keys
router_with_role_tokens plus the keys.json set (see AccessKeys).
router_with_auth
router with an optional bearer/?token= requirement on every route except unauthenticated GET /health.
router_with_cors
router_with_auth with an explicit CORS layer (see crate::parse_cors_origins). None adds no CORS headers. The other routers read MUSHROOMDB_CORS_ORIGINS instead; this one ignores the environment.
router_with_ready_flag
router_with_auth whose GET /ready follows ready: 503 while it is false, 200 once it is true. Every other router is ready as soon as it is built.
router_with_role_tokens
router with a full-access token and a map of role-bound tokens.
router_with_tx_limits
router_with_access_keys with the open-transaction limits given instead of read from MUSHROOMDB_TX_MAX and MUSHROOMDB_TX_TIMEOUT_SECS. For an embedder that serves several routers, and for tests that need a short idle timeout.
router_with_ui
Same as router_with_auth, then ServeDir as the fallback so API routes win.
router_with_ui_tls
Like router_with_ui but marks the connection as TLS-active so the auth cookie carries the Secure attribute. Use when the binary is serving directly over HTTPS (i.e. via serve_tls) rather than behind a proxy.
run_mcp_stdio
Run the MCP loop until reader hits EOF.
run_mcp_stdio_with
run_mcp_stdio, with the tool list chosen by the caller.
serve_with_role_tokens
[serve] with role-bound tokens in addition to the optional full-access token.
serve_with_role_tokens_and_shutdown
serve_with_role_tokens that stops gracefully. See serve_with_shutdown.
serve_with_role_tokens_and_shutdown_with_ready_flag
serve_with_role_tokens_and_shutdown whose GET /ready follows ready_flag.
serve_with_shutdown
The graceful-shutdown variants, added in 0.6.12.
serve_with_ui_and_role_tokens
[serve_with_ui] with role-bound tokens.
serve_with_ui_and_role_tokens_and_shutdown
serve_with_ui_and_role_tokens that stops gracefully. See serve_with_shutdown.
serve_with_ui_and_role_tokens_and_shutdown_with_ready_flag
serve_with_ui_and_role_tokens_and_shutdown whose GET /ready follows ready_flag.
watch_sighup
Re-reads keys from its file whenever the process gets SIGHUP.