Skip to content

Commit

Permalink
chore(shuttle-turso): update libsql dep (#1694)
Browse files Browse the repository at this point in the history
* chore(shuttle-turso): bump libsql dependency

* refactor(turso): replace deprecated Database::open with Builder

---------

Co-authored-by: jonaro00 <54029719+jonaro00@users.noreply.github.com>
  • Loading branch information
Jaco-Minnaar and jonaro00 committed Mar 25, 2024
1 parent c437091 commit bd9466f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion resources/turso/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ keywords = ["shuttle-service", "turso"]
[dependencies]
async-trait = "0.1.56"
dunce = "1.0.4"
libsql = { version = "0.2.0", default-features = false, features = ["core", "remote"] }
libsql = { version = "0.3.1", default-features = false, features = ["core", "remote"] }
serde = { version = "1", features = ["derive"] }
shuttle-service = { path = "../../service", version = "0.42.0" }
url = { version = "2.3.1", features = ["serde"] }
Expand Down
8 changes: 5 additions & 3 deletions resources/turso/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use async_trait::async_trait;
use libsql::{Connection, Database};
use libsql::{Builder, Connection};
use serde::{Deserialize, Serialize};
use shuttle_service::{
error::{CustomError, Error as ShuttleError},
Expand Down Expand Up @@ -123,16 +123,18 @@ impl ResourceInputBuilder for Turso {
impl IntoResource<Connection> for TursoOutput {
async fn into_resource(self) -> Result<Connection, shuttle_service::Error> {
let database = if self.remote {
Database::open_remote(
Builder::new_remote(
self.conn_url.to_string(),
self.token
.clone()
.ok_or(ShuttleError::Custom(CustomError::msg(
"missing token for remote database",
)))?,
)
.build()
.await
} else {
Database::open(self.conn_url.to_string())
Builder::new_local(self.conn_url.to_string()).build().await
};
database
.map_err(|err| ShuttleError::Custom(err.into()))?
Expand Down

0 comments on commit bd9466f

Please sign in to comment.