shuttle-hq / shuttle

Build & ship backends without writing any infrastructure files.
https://shuttle.rs
Apache License 2.0
6.1k stars 253 forks source link

[Feature]: libsql crate support for turso #1406

Closed supercoolspy closed 9 months ago

supercoolspy commented 1 year ago

Describe the feature

This allows users to use the more beta libsql crate as opposed to the libsql_client crate which has some nicer features along with being Send+Sync (Connection at least)

Suggestion or Example of how the feature would be used

Pass in a libsql::Database object instead of a libsql_client::Client and then it would be available

Duplicate declaration

supercoolspy commented 1 year ago

Also I'd be happy to do this just want to make sure there isn't any issues with the idea

joshua-mo-143 commented 12 months ago

Just wanted to throw this extra footnote in here for the Engineering team but it looks like we can re-build the Turso database connection pretty easily according to this example since the remote connect method allows for a URL and an auth token (just like with the libsql_client crate): https://github.com/tursodatabase/libsql/blob/main/libsql/examples/example_v2.rs

jonaro00 commented 12 months ago

Could you motivate further why libsql would be the better choice? libsql_client uses it internally for the "local backend" for local files. The latter is also more feature complete and is the recommended library to use.

supercoolspy commented 11 months ago

https://github.com/libsql/libsql-client-rs/issues/52#issuecomment-1847968384 Just found this out, sorry for the late response

jonaro00 commented 11 months ago

Looks good. We can't publish crates with git dependencies, so we need to wait until they publish theirs in order to support it.

supercoolspy commented 11 months ago

Alright can 100% do this when it gets published

Mouwrice commented 10 months ago

@jonaro00 @supercoolspy So I have been following Turso a bit and the new libsql crate has been published (https://crates.io/crates/libsql) and is now preferred.^1

At the time of writing, their documentation pages are not entirely up-to-date, so expect to see some references to the 'old' libsql-client (https://docs.turso.tech/sdk/rust/quickstart). But both the examples and crate docs are available. (https://github.com/tursodatabase/libsql/tree/main/libsql/examples, https://docs.rs/libsql/0.2.0/libsql/)

jonaro00 commented 10 months ago

Awesome :D . Feel free to try it out in shuttle-turso and make a PR if it works well.

Mouwrice commented 10 months ago

Awesome :D . Feel free to try it out in shuttle-turso and make a PR if it works well.

@jonaro00 I have a draft PR open which migrates to the new libsql crate https://github.com/shuttle-hq/shuttle/pull/1531 The changes on the shuttle side are pretty simple. There might be some changes to how database url's are handled, so I am waiting for a response by the shuttle team on that. Other than that, I feel that most is described in the PR itself. Being my first contribution I am not sure on how to properly test these changes (the unit tests succeed at least). What I can and plan to do is see how it works with a project of mine that makes use of shuttle and shuttle-turso.

I hope this contribution is useful and let me know what I might have missed!