From 536d20b20cb016213988c275187cf2e0da735cfd Mon Sep 17 00:00:00 2001 From: Jaco Minnaar Date: Wed, 20 Mar 2024 12:19:19 +0200 Subject: [PATCH 1/2] chore(shuttle-turso): bump libsql dependency --- resources/turso/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/turso/Cargo.toml b/resources/turso/Cargo.toml index 1d66be1f2..752dea956 100644 --- a/resources/turso/Cargo.toml +++ b/resources/turso/Cargo.toml @@ -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"] } From 3bc1afe44b50a06e3d1e91a00ce762e3151386bb Mon Sep 17 00:00:00 2001 From: Jaco Minnaar Date: Wed, 20 Mar 2024 12:20:04 +0200 Subject: [PATCH 2/2] refactor(turso): replace deprecated Database::open with Builder --- resources/turso/src/lib.rs | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/resources/turso/src/lib.rs b/resources/turso/src/lib.rs index 0b93b5c40..4bc2e53b5 100644 --- a/resources/turso/src/lib.rs +++ b/resources/turso/src/lib.rs @@ -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}, @@ -123,15 +123,19 @@ impl ResourceInputBuilder for Turso { impl IntoResource for TursoOutput { async fn into_resource(self) -> Result { let database = match self.environment { - Environment::Deployment => Database::open_remote( - self.conn_url.to_string(), - self.token - .clone() - .ok_or(ShuttleError::Custom(CustomError::msg( - "missing token for remote database", - )))?, - ), - Environment::Local => Database::open(self.conn_url.to_string()), + Environment::Deployment => { + Builder::new_remote( + self.conn_url.to_string(), + self.token + .clone() + .ok_or(ShuttleError::Custom(CustomError::msg( + "missing token for remote database", + )))?, + ) + .build() + .await + } + Environment::Local => Builder::new_local(self.conn_url.to_string()).build().await, }; database .map_err(|err| ShuttleError::Custom(err.into()))?