From cababc43dbb37370eb4d8e3884e66a55d1c1bdc6 Mon Sep 17 00:00:00 2001 From: Ryan Date: Mon, 5 Aug 2024 17:00:36 +0900 Subject: [PATCH] 0.1.8 --- RELEASE_NOTE.md | 6 +++++- src/aws/s3.rs | 23 ----------------------- src/database.rs | 11 ++++++----- 3 files changed, 11 insertions(+), 29 deletions(-) diff --git a/RELEASE_NOTE.md b/RELEASE_NOTE.md index ababdf0..a2b7520 100644 --- a/RELEASE_NOTE.md +++ b/RELEASE_NOTE.md @@ -32,4 +32,8 @@ first deploy 0.1.7 ====== - added s3 bucket constant -- fix some constant name(underline -> dash) \ No newline at end of file +- fix some constant name(underline -> dash) + +0.1.8 +====== +- added campaign database information \ No newline at end of file diff --git a/src/aws/s3.rs b/src/aws/s3.rs index ff98bfa..3538dec 100644 --- a/src/aws/s3.rs +++ b/src/aws/s3.rs @@ -58,27 +58,4 @@ pub async fn read_file(bucket: &str, key: &str) -> Result { } Ok(String::from_utf8_lossy(&data).into_owned()) -} - -#[cfg(test)] -mod tests { - use super::*; - use serial_test::serial; - use crate::constants; - - fn setup() { - crate::env::set(constants::ENV_AWS_ACCESS_KEY, "AKIA32XY6L3KQA4QDIAP"); - crate::env::set(constants::ENV_AWS_SECRET_KEY, "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"); - crate::env::set(constants::ENV_AWS_REGION, "ap-northeast-2"); - } - - fn teardown() {} - - #[tokio::test] - #[serial] - async fn test_read_file() { - setup(); - assert!(read_file("apm-bigdata", "flower-device/test.csv").await.is_ok()); - teardown(); - } } \ No newline at end of file diff --git a/src/database.rs b/src/database.rs index d48d5a4..496e4b3 100644 --- a/src/database.rs +++ b/src/database.rs @@ -2,6 +2,7 @@ use std::sync::Arc; use deadpool_postgres::{Pool, Config, Runtime}; use tokio::sync::OnceCell; use tokio_postgres::NoTls; +use crate::aws::s3::read_file; use crate::config::get_config; static CONNECTION_POOL: OnceCell> = OnceCell::const_new(); @@ -32,11 +33,11 @@ async fn initialize_campaign_connection_pool() -> Arc { let config = get_config().await; let mut pg = Config::new(); - pg.host = Some(config.database.host.clone()); - pg.user = Some(config.database.user.clone()); - pg.password = Some(config.database.password.clone()); - pg.dbname = Some(config.database.name.clone()); - pg.port = Some(config.database.port as u16); + pg.host = Some(config.campaign_database.host.clone()); + pg.user = Some(config.campaign_database.user.clone()); + pg.password = Some(config.campaign_database.password.clone()); + pg.dbname = Some(config.campaign_database.name.clone()); + pg.port = Some(config.campaign_database.port as u16); let pool = pg.create_pool(Some(Runtime::Tokio1), NoTls).unwrap();