From 721892c0059312ad5cd9136d12bbd6a5f2ee1e31 Mon Sep 17 00:00:00 2001 From: Roman Valls Guimera Date: Fri, 17 Nov 2023 10:45:17 +1100 Subject: [PATCH] Bump AWS deps and fixup some changes, unsure if this skel represents a good cargo-generate repo, but it's better than nothing --- skel/rust-api/Cargo.toml | 8 ++++---- skel/rust-api/src/db.rs | 7 +++---- skel/rust-api/src/file.rs | 4 ++-- skel/rust-api/src/main.rs | 12 +++++++++--- 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/skel/rust-api/Cargo.toml b/skel/rust-api/Cargo.toml index 6bd16643c..0db9117fe 100644 --- a/skel/rust-api/Cargo.toml +++ b/skel/rust-api/Cargo.toml @@ -10,7 +10,7 @@ lambda_http = "0.8" lambda_runtime = "0.8" serde = { version = "1", features = ["derive"] } serde_json = "1" -sqlx = { version = "0.7", features = ["mysql", "runtime-tokio-rustls", "chrono"] } +sqlx = { version = "0.7", features = ["mysql", "runtime-tokio-rustls", "chrono", "macros"] } tokio = { version = "1", features = ["rt-multi-thread", "macros"] } utoipa = { version = "4", features = ["axum_extras"] } utoipa-swagger-ui = { version = "4", features = ["axum"] } @@ -25,6 +25,6 @@ thiserror = "1.0" async-trait = "0.1" # S3 Dependencies -aws-config = "0.56" -aws-sdk-s3 = "0.29" -aws-sdk-sqs = "0.29" \ No newline at end of file +aws-config = "0.100" +aws-sdk-s3 = "0.37" +aws-sdk-sqs = "0.37" \ No newline at end of file diff --git a/skel/rust-api/src/db.rs b/skel/rust-api/src/db.rs index bcf8400d4..220a4b48a 100644 --- a/skel/rust-api/src/db.rs +++ b/skel/rust-api/src/db.rs @@ -1,5 +1,4 @@ use std::env; -use std::error::Error; use crate::error; use sqlx::{mysql::MySqlPool, FromRow}; @@ -30,7 +29,7 @@ pub struct S3 { } impl FileAdapter for S3 { - fn find(&self, query: Attributes) -> error::Result> { + fn find(&self, _query: Attributes) -> error::Result> { todo!(); // Ok(vec![File { // id: self.id, @@ -39,10 +38,10 @@ impl FileAdapter for S3 { } } -pub async fn s3_query_something(name: String) -> Result, sqlx::Error> { +pub async fn s3_query_something(_name: String) -> Result, sqlx::Error> { // TODO: Move this at "class" level instead of method level let db_url = env::var("DATABASE_URL"); - let pool = MySqlPool::connect(db_url.unwrap_or_default().as_str()).await?; + let _pool = MySqlPool::connect(db_url.unwrap_or_default().as_str()).await?; todo!(); // let key = "foo"; diff --git a/skel/rust-api/src/file.rs b/skel/rust-api/src/file.rs index 341550e06..9f46b9518 100644 --- a/skel/rust-api/src/file.rs +++ b/skel/rust-api/src/file.rs @@ -1,4 +1,4 @@ -use std::error::Error; +//use std::error::Error; use axum::{extract::Query, Json}; use serde::{Deserialize, Serialize}; @@ -76,7 +76,7 @@ pub enum FileError { )] pub async fn search(query: Query) -> Result>> { info!("searching {:?}", query.name); - let res = crate::db::s3_query_something(query.name.clone()) + let _res = crate::db::s3_query_something(query.name.clone()) .await .map_err(|e| NotFound(e.to_string()))?; diff --git a/skel/rust-api/src/main.rs b/skel/rust-api/src/main.rs index 5d4711a80..9f3c661cf 100644 --- a/skel/rust-api/src/main.rs +++ b/skel/rust-api/src/main.rs @@ -1,7 +1,6 @@ use std::net::{Ipv4Addr, SocketAddr}; use axum::{routing, Router, Server}; -use hyper::Error; use rust_api::env; use rust_api::file; @@ -30,7 +29,7 @@ use tracing::{info, Level}; /// 2. Link objects/paths to metadata: That would tightly couple filemanager with metadata service. #[tokio::main] -async fn main() -> Result<(), Error> { +async fn main() -> Result<(), hyper::Error> { tracing_subscriber::fmt() .with_target(false) .compact() @@ -54,5 +53,12 @@ async fn main() -> Result<(), Error> { let address = SocketAddr::from((Ipv4Addr::UNSPECIFIED, 8080)); info!("listening on {}", address); - Server::bind(&address).serve(app.into_make_service()).await + let server = Server::bind(&address).serve(app.into_make_service()); + + // Run forever-ish... + if let Err(err) = server.await { + eprintln!("server error: {}", err); + } + + Ok(()) }