From 36dcced3988824c99577a3f1eba1352fb5887bf3 Mon Sep 17 00:00:00 2001 From: Ryan Date: Wed, 7 Aug 2024 18:25:20 +0900 Subject: [PATCH] 0.1.10 --- Cargo.toml | 2 +- README.md | 2 +- RELEASE_NOTE.md | 48 +++++++++++++++++++++++++--------------------- src/aws/kinesis.rs | 6 +++--- src/config.rs | 27 ++++++++++++++++++++++---- src/constants.rs | 3 +-- 6 files changed, 55 insertions(+), 33 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index eca2a66..74fd64d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "device-common" -version = "0.1.9" +version = "0.1.10" edition = "2021" authors = ["Ryan Bae "] diff --git a/README.md b/README.md index 67df8f5..90e499f 100644 --- a/README.md +++ b/README.md @@ -11,4 +11,4 @@ device-service 에서 공통으로 쓰이는 기능들의 집합 - string.rs : string 확장 기능 - aws/kinesis.rs : AWS Kinesis Stream 관련 기능 - aws/parameter_store.rs : AWS Parameter Store 관련 기능 -- aws/s3.rs : AWS S3 관련 기능] \ No newline at end of file +- aws/s3.rs : AWS S3 관련 기능 \ No newline at end of file diff --git a/RELEASE_NOTE.md b/RELEASE_NOTE.md index 0f8e703..dc5be5a 100644 --- a/RELEASE_NOTE.md +++ b/RELEASE_NOTE.md @@ -1,43 +1,47 @@ -0.1.0 +0.1.10 ====== -first deploy +- config.rs 에 s3 관련 추가 -0.1.1 +0.1.9 ====== -- write test code sample -- used tokio::sync::oncecell instead of std::sync::oncelock for async +- added string.rs -0.1.2 +0.1.8 ====== -- create log directory +- added campaign database information -0.1.3 +0.1.7 ====== -- remove s3 dependency(rusoto_core, rusoto_s3) +- added s3 bucket constant +- fix some constant name(underline -> dash) -0.1.4 +0.1.6 ====== -- fix bug for using toml library +- changed kinesis_message(byte struct) to string(json) +- added 'aws' directory +- added s3.rs 0.1.5 ====== - fix bug for log -0.1.6 +0.1.4 ====== -- changed kinesis_message(byte struct) to string(json) -- added 'aws' directory -- added s3.rs +- fix bug for using toml library -0.1.7 +0.1.3 ====== -- added s3 bucket constant -- fix some constant name(underline -> dash) +- remove s3 dependency(rusoto_core, rusoto_s3) -0.1.8 +0.1.2 ====== -- added campaign database information +- create log directory -0.1.9 +0.1.1 +====== +- write test code sample +- used tokio::sync::oncecell instead of std::sync::oncelock for async + +0.1.0 ====== -- added string.rs \ No newline at end of file +first deploy \ No newline at end of file diff --git a/src/aws/kinesis.rs b/src/aws/kinesis.rs index 89c7dda..b982306 100644 --- a/src/aws/kinesis.rs +++ b/src/aws/kinesis.rs @@ -12,9 +12,9 @@ async fn initialize_data() -> Arc { let config = crate::config::get_config() .await; - let access_key_id = &config.kinesis_stream.node.access_key.clone(); - let secret_access_key = &config.kinesis_stream.node.secret_key.clone(); - let region = &config.kinesis_stream.node.region.clone(); + let access_key_id = &config.aws.access_key.clone(); + let secret_access_key = &config.aws.secret_key.clone(); + let region = &config.aws.region.clone(); let credentials = Credentials::from_keys(access_key_id, secret_access_key, None); let aws_config = Config::builder() diff --git a/src/config.rs b/src/config.rs index 3376a56..cd02526 100644 --- a/src/config.rs +++ b/src/config.rs @@ -31,10 +31,14 @@ pub struct Database { } #[derive(Debug, PartialEq, Serialize, Deserialize)] -pub struct AwsKinesisStreamDetail { +pub struct Aws { pub access_key: String, pub secret_key: String, pub region: String, +} + +#[derive(Debug, PartialEq, Serialize, Deserialize)] +pub struct AwsKinesisStreamDetail { pub name: String, pub partition_key: String, pub arn: String, @@ -45,11 +49,18 @@ pub struct AwsKinesisStream { pub node: AwsKinesisStreamDetail, } +#[derive(Debug, PartialEq, Serialize, Deserialize)] +pub struct AwsS3 { + pub bucket: String, +} + #[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct Config { pub database: Database, pub campaign_database: Database, pub rabbitmq: Rabbitmq, + pub aws: Aws, + pub s3: AwsS3, pub kinesis_stream: AwsKinesisStream, } @@ -102,11 +113,19 @@ async fn initialize_data() -> Arc { queue: get_parameter(constants::RABBITMQ_ORCHESTRATION_QUEUE_KEY.to_string()).await, }, }, + + aws: Aws { + access_key: crate::env::get(constants::ENV_AWS_ACCESS_KEY).expect_or_log("env aws_access_key not found"), + secret_key: crate::env::get(constants::ENV_AWS_SECRET_KEY).expect_or_log("env aws_secret_key not found"), + region: crate::env::get(constants::ENV_AWS_REGION).expect_or_log("env aws_region not found"), + }, + + s3: AwsS3 { + bucket: get_parameter(constants::S3_BUCKET.to_string()).await + }, + kinesis_stream: AwsKinesisStream { node: AwsKinesisStreamDetail { - access_key: crate::env::get(constants::ENV_AWS_ACCESS_KEY).expect_or_log("env aws_access_key not found"), - secret_key: crate::env::get(constants::ENV_AWS_SECRET_KEY).expect_or_log("env aws_secret_key not found"), - region: crate::env::get(constants::ENV_AWS_REGION).expect_or_log("env aws_region not found"), name: get_parameter(constants::KINESIS_PERSISTENCE_NAME_KEY.to_string()).await, partition_key: get_parameter(constants::KINESIS_PERSISTENCE_PARTITION_KEY.to_string()).await, arn: get_parameter(constants::KINESIS_PERSISTENCE_ARN_KEY.to_string()).await, diff --git a/src/constants.rs b/src/constants.rs index d6d8f26..736f6b8 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -20,8 +20,7 @@ pub const KINESIS_FAILOVER_NAME_KEY: &str = "/flower/device/failover/kinesis/nam pub const KINESIS_FAILOVER_PARTITION_KEY: &str = "/flower/device/failover/kinesis/partition-key"; pub const KINESIS_FAILOVER_ARN_KEY: &str = "/flower/device/failover/kinesis/arn"; -pub const S3_BUCKET: &str = "/flower/device/common/s3/bucket"; -pub const S3_PATH: &str = "/flower/device/common/s3/path"; +pub const S3_BUCKET: &str = "/flower/device/common/aws/s3/bucket"; pub const DB_HOST_KEY: &str = "/flower/device/common/db/host"; pub const DB_PORT_KEY: &str = "/flower/device/common/db/port";