-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for LibSQL remote #11385
Conversation
🦋 Changeset detectedLatest commit: 9d0d588 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing how simple the changes that are required to unlock the potential of this library, I could see many people very happy about this change! since it will also allow more "Self-hosted-production" database options!
I'm very happy and confident that this PR unlocks new use cases for Astro DB. I hope it gets merged soon. |
Thank you @Fryuni. I'll make sure that Core is aware of this PR :) |
How is this working? Is this because the libsql db has an https URL? Any links you can share? Seems exciting. |
It uses the DB itself to manage the snapshots, like Studio did back in the closed beta.
LibSQL has two APIs, one exclusively over HTTP and one using the Hrana protocol, which can work both over HTTP or over WebSockets or a combination of both. The Hrana protocol allows for stateful connections, so transactions are supported.
Besides the specs above, the supported URL protocols are described in LibSQL's type docs. It links to a section of the README that was removed during some reorganization of the repo a few months ago. The LibSQL client uses the Hrana protocol. The given URL can have Since Studio already uses |
To test it out, I have this route deployed using this branch and configured to use an embedded in-memory replica synchronizing with Turso. Working perfectly :) |
@Fryuni Fred is out this week, he has the most context for how migrations work, so when he gets back he'll review this and leave any feedback. |
@Fryuni Plan is still to have this in for 4.13 |
Just noting that if this goes through, we will want docs for how someone can do this in the DB guide! |
!preview db-remote |
Hey @Fryuni ! Friendly ping to remind you that I'd normally want to have a docs PR reviewed before approving an astro PR, so I know how to make helpful suggestions to the changeset here! And, this content is what helps Erika write the release blog post so she knows how to hype your feature! Since PRs will be merged tomorrow for the minor, can I help you in any way to get a docs PR together today? |
I got caught up with some things recently, but I'll have a PR for docs today 😁 |
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving for docs! 🥳
if (error.code === 'SQLITE_UNKNOWN') { | ||
// Snapshots table was not created yet, | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you expand the current comment and explain why this error doesn't need to be handled? Still, I think it's valuable to have a log of the error.
It does seem a bit odd to me to reuse the environment variables for Studio to connect to something non-studio. Can we not have different variables for this use-case? Would that be a problem? |
We'll be releasing this outside of the minor, as there's still some concerns to be addressed. |
[skip ci] Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>
I explained that on Discord to Sarah, but it might have gotten lost there: Since the Studio side is closed source, I don't know what would break internally if I changed the name of the env var. If it were just DB, I'd have renamed it to something like I'll refactor the code to accept different values, here is what I'm thinking:
This way, it should not change anything about configuring the Studio connection while also adding LibSQL support. What do you guys think? |
@Fryuni I like the proposal! :) |
@Fryuni sorry for the late reply, yes that sounds good! Basically just treat this as a new feature that's unrelated to the Astro Studio flow. So your proposal sounds good. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still approving for docs, and wondering whether this will be included in 4.15!
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Changes
ASTRO_DB_REMOTE_URL
pointing to a LibSQL server instance (using any supported LibSQL protocols), to a file, or to an in-memory DB. This enables Astro DB to be used with self-hosting and air-gapped deployments.memory:?syncUrl=libsql%3A%2F%2Fdb-server.example.com
would create an in-memory embedded replica for the LibSQL DB onlibsql://db-server.example.com
.Testing
Replicated the test for Studio remote using the LibSQL remote
Docs