Repository navigation
ADR-053: DatabaseService gRPC server (local-database registry) - #1592
Conversation
…053) Implement the client-facing DatabaseService — the reachable path that makes per-request database routing user-visible. It wraps the existing DatabaseManager and exposes List/Create/Register/Remove/SetDefault/Rename over the already-generated proto. The service is process-global (operates on the registry itself, not a single database) so it is not routed by the x-ns-database-id header. Mutating RPCs re-read the registry snapshot to build the DatabaseInfo response so status and is_default reflect the write; unknown-id mutations map to NotFound. Wire it into BaseServices + build_base_router and all four serve loops, cloning the manager already opened for the default database (no double-open). Adding the field to BaseServices keeps the ADR-043 compile-time contract: nodespaced-pro must provide the impl when it bumps its core pin. Add an end-to-end gRPC test that drives the real transport: the DbManagerLayer injects the manager over the wire, Create registers a second database, and a header-routed NodeService write lands in it — visible with the header, NotFound without it, and the second database flips to Open. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
APPROVE — with a hard cross-repo lock-step flag (below); the code itself is correct. What I verified
|
Part of the ADR-053 epic ("One Daemon, Multiple Local Databases", #1532). This adds the client-facing
DatabaseService— the reachable path that makes the per-request database routing built in Stages 1–5 user-visible. Until now a client had no way to register a second database, so routing was exercised only in tests; production always resolved to the single default.What changed
DatabaseServiceImpl(services/database_service.rs) wraps the existingDatabaseManagerand implements the already-generated proto:List/Create/Register/Remove/SetDefault/Rename. The manager already had every method these need — this is the gRPC adapter over it.x-ns-database-idheader. Mutating RPCs re-read the registry snapshot to build theDatabaseInforesponse, sostatus/is_defaultreflect the write just applied. Unknown-id mutations map toNotFound; create/register IO failures map toInternal.BaseServices+build_base_router+ all four serve loops, cloning theArc<DatabaseManager>already opened for the default database (no double-open).Cross-repo (ADR-043)
Adding
databasetoBaseServicesis the intended compile-time contract:nodespaced-promust provide the impl when it bumps its core pin. That is a coordinated follow-up on thenodespace-syncside (bump pin + seed a manager with the active database); the Pro daemon installs no routing layer, so its data/sync path is unchanged and multi-database-under-one-cloud-session stays an explicit deferral.Verification
cargo fmt --check,cargo clippy --all-targets -- -D warnings— clean.cargo test -p nodespace-daemon— 51 lib (+3 newDatabaseServiceunit tests) + all integration suites green.tests/database_service_e2e.rs) drives the real tonic transport: theDbManagerLayerinjects the manager over the wire →Createregisters a second database → a header-routedNodeServicewrite lands in it (visible with the header,NotFoundwithout it — real isolation), the second database flips toOpen, and an unregistered header is rejected.