Skip to content

feat: add support for dynamically pathed dbs - #77

Merged
velocitysystems merged 1 commit into
silvermine:masterfrom
onehumandev:onehumandev/dynamic_pathing
Nov 6, 2026
Merged

velocitysystems merged 1 commit into
silvermine:masterfrom
onehumandev:onehumandev/dynamic_pathing

Conversation

@onehumandev

Copy link
Copy Markdown
Contributor

Until now, we have required db paths to be constant for the lifetime of an app to be accessed by a db key string.

This now needs to be modified to support paths that may change during runtime.

For example, if we have profile-specific dbs in an app, and the user is allowed to switch profiles during runtime, we want the key to that db to remain the same, while allowing the actual path to change to the requested db.

@onehumandev
onehumandev requested a review from a team November 5, 2026 21:46
@jjhafer

jjhafer commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

@velocitysystems Can you review this?

@onehumandev

Copy link
Copy Markdown
Contributor Author

Looking at CI failures presently

@onehumandev
onehumandev force-pushed the onehumandev/dynamic_pathing branch from 05ef767 to a9462f6 Compare November 5, 2026 21:56
Comment thread src/lib.rs Resolved
Comment thread src/lib.rs Resolved
Comment thread README.md Resolved
Comment thread src/lib.rs Resolved
Comment thread src/lib.rs Resolved
Comment thread src/lib.rs Resolved
Comment thread src/lib.rs Resolved
Comment thread src/lib.rs Resolved
Comment thread src/lib.rs Resolved
Comment thread src/lib.rs Resolved
@onehumandev
onehumandev force-pushed the onehumandev/dynamic_pathing branch from a9462f6 to 6fece8d Compare November 5, 2026 22:42
@onehumandev

Copy link
Copy Markdown
Contributor Author

Looking at CI failures presently

@velocitysystems Looks like the cargo deny failure is new, but not caused by any changes in this MR. I see that we've been updating the CI pipeline recently; any thoughts on how best to fix this?

@velocitysystems

Copy link
Copy Markdown
Contributor

Looking at CI failures presently

@velocitysystems Looks like the cargo deny failure is new, but not caused by any changes in this MR. I see that we've been updating the CI pipeline recently; any thoughts on how best to fix this?

Fixed by #78.

Comment thread src/lib.rs Resolved
Comment thread README.md Resolved
Comment thread CHANGELOG.md Resolved
Comment thread src/lib.rs Resolved
Comment thread src/lib.rs Resolved
Comment thread src/lib.rs Resolved
Comment thread src/lib.rs Resolved
Comment thread guest-js/index.ts Resolved
Comment thread src/lib.rs Resolved
@onehumandev
onehumandev force-pushed the onehumandev/dynamic_pathing branch 2 times, most recently from d058044 to f173dbf Compare November 6, 2026 15:21
@velocitysystems

Copy link
Copy Markdown
Contributor

@onehumandev Cargo Deny issue has been resolved. Can you please rebase?

@onehumandev
onehumandev force-pushed the onehumandev/dynamic_pathing branch from f173dbf to 77a31b2 Compare November 6, 2026 16:02
@onehumandev

Copy link
Copy Markdown
Contributor Author

@onehumandev Cargo Deny issue has been resolved. Can you please rebase?

Rebased 👍

Comment thread guest-js/index.ts Resolved
@onehumandev
onehumandev force-pushed the onehumandev/dynamic_pathing branch from 77a31b2 to fec2668 Compare November 6, 2026 16:21
@onehumandev
onehumandev force-pushed the onehumandev/dynamic_pathing branch from fec2668 to d3a3f54 Compare November 6, 2026 16:27
Comment thread src/lib.rs Resolved
Comment thread guest-js/index.ts Resolved
Until now, we have required db paths to be constant for the lifetime
of an app to be accessed by a db key string.

This now needs to be modified to support paths that may change during
runtime.

For example, if we have profile-specific dbs in an app, and the user
is allowed to switch profiles during runtime, we want the key to that
db to remain the same, while allowing the actual path to change
to the requested db.
@onehumandev
onehumandev force-pushed the onehumandev/dynamic_pathing branch from d3a3f54 to fdeb6d0 Compare November 6, 2026 18:17
Comment thread src/lib.rs

let _registration_lock = registered.registration_lock.lock().await;

if migration_is_unsettled(&migration_states, db_key).await {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 P3 (non-blocking follow-up) — Return the migration error when this key is Failed under the lock

Non-blocking. Under the lock, a Failed state passes this check, and connect_to_database_locked no longer checks migrations. So a connect that queued behind a Replace whose new migration fails can load that database and return Ok. Add await_migrations(&migration_states, db_key).await?; after this block. The state is settled here and only register_database changes it under this lock, so the call returns at once and maps Failed to the error. Then update the comment below, which says not to call it here.

Comment added by AI model Claude

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@onehumandev Can you please evaluate whether this is worth doing as a follow-up? Thanks!

@velocitysystems
velocitysystems merged commit 9b49e72 into silvermine:master Nov 6, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants