Skip to content

Commit

Permalink
Bump AWS deps and fixup some changes, unsure if this skel represents …
Browse files Browse the repository at this point in the history
…a good cargo-generate repo, but it's better than nothing
  • Loading branch information
brainstorm committed Nov 16, 2023
1 parent 460ca72 commit 721892c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
8 changes: 4 additions & 4 deletions skel/rust-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand All @@ -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"
aws-config = "0.100"
aws-sdk-s3 = "0.37"
aws-sdk-sqs = "0.37"
7 changes: 3 additions & 4 deletions skel/rust-api/src/db.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::env;
use std::error::Error;

use crate::error;
use sqlx::{mysql::MySqlPool, FromRow};
Expand Down Expand Up @@ -30,7 +29,7 @@ pub struct S3 {
}

impl FileAdapter for S3 {
fn find(&self, query: Attributes) -> error::Result<Vec<File>> {
fn find(&self, _query: Attributes) -> error::Result<Vec<File>> {
todo!();
// Ok(vec![File {
// id: self.id,
Expand All @@ -39,10 +38,10 @@ impl FileAdapter for S3 {
}
}

pub async fn s3_query_something(name: String) -> Result<Vec<S3>, sqlx::Error> {
pub async fn s3_query_something(_name: String) -> Result<Vec<S3>, 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";
Expand Down
4 changes: 2 additions & 2 deletions skel/rust-api/src/file.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::error::Error;
//use std::error::Error;

use axum::{extract::Query, Json};
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -76,7 +76,7 @@ pub enum FileError {
)]
pub async fn search(query: Query<File>) -> Result<Json<Vec<File>>> {
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()))?;

Expand Down
12 changes: 9 additions & 3 deletions skel/rust-api/src/main.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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()
Expand All @@ -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(())
}

0 comments on commit 721892c

Please sign in to comment.