Skip to content
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

Issue with shuttle-turbo #289

Closed
francisstephan opened this issue Aug 17, 2024 · 2 comments
Closed

Issue with shuttle-turbo #289

francisstephan opened this issue Aug 17, 2024 · 2 comments

Comments

@francisstephan
Copy link

Path: /resources/shuttle-turso
When I implement the code snippet in the docs I get the following error at compilation:
error[E0277]: the trait bound TursoOutput: IntoResource<Connection> is not satisfied
--> src/main.rs:17:1
|
17 | #[shuttle_runtime::main]
| ^^^^^^^^^^^^^^^^^^^^^^^^ the trait IntoResource<Connection> is not implemented for TursoOutput
|
= help: the trait IntoResource<libsql::database::Database> is implemented for TursoOutput
= help: for that trait implementation, expected libsql::database::Database, found Connection
= note: this error originates in the attribute macro shuttle_runtime::main (in Nightly builds, run with -Z macro-backtrace for more info)
Here is my Cargo.toml:
[package]
name = "chinese-writer"
version = "0.1.0"
edition = "2021"

[dependencies]
axum = { version="0.7.5", features=["macros","form"] }
lazy_static = "1.5.0"
libsql = "0.5.0"
serde = "1.0.207"
shuttle-axum = "0.47.0"
shuttle-runtime = "0.47.0"
shuttle-turso = "0.47.0"
tera = "1.20.0"
tokio = "1.28.2"
tower-http = { version="0.5.2", features=["fs"] }

and my main.rs:

use axum::{
routing::get,
Router,
};
use libsql::Connection;
use tower_http::services::ServeDir;
use shuttle_axum::ShuttleAxum;
mod handlers;

#[shuttle_runtime::main]
async fn app(
#[shuttle_turso::Turso(
addr="libsql://zidian-francisstephan.turso.io",
token="{secrets.DB_TURSO_TOKEN}")]
client: Connection
)-> shuttle_axum::ShuttleAxum {
let router = Router::new()
.route("/", get(handlers::index))
.nest_service("/assets", ServeDir::new("./vol/assets"));

Ok(router.into())

}

@joshua-mo-143
Copy link
Member

joshua-mo-143 commented Sep 11, 2024

Hey there - thanks for letting us know!

This does looks like it needs correcting. You need to use libsql::Database as per the updated source code, as using a connection tends to time out if you don't use it for more than 10-15s and cause the connection to not work anymore.

@joshua-mo-143
Copy link
Member

Fixed by #292

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

No branches or pull requests

2 participants