pub fn router(db: SharedDb) -> RouterExpand description
Build the HTTP router over db. Read endpoints 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.
Call at most once per SharedDb. A second call replaces the sink
and terminates all existing /watch subscribers with
tokio::sync::broadcast::error::RecvError::Closed.
Installing the watch sink replaces any previously installed
core_api::GraphDb::set_event_sink. The sink only
broadcast::Sender::sends (non-blocking) and never re-enters db.
§Blocking
SharedDb uses a std std::sync::RwLock. Write handlers
(query_write, /ingest, create_rule) run in
tokio::task::spawn_blocking and drop the write guard before .await.
Reads stay on the worker (neighborhood is µs). suggest and algo
already use the blocking pool.