Browse Source

0.1.10

master 0.1.10
Ryan 1 year ago
parent
commit
36dcced398
  1. 2
      Cargo.toml
  2. 2
      README.md
  3. 48
      RELEASE_NOTE.md
  4. 6
      src/aws/kinesis.rs
  5. 25
      src/config.rs
  6. 3
      src/constants.rs

2
Cargo.toml

@ -1,6 +1,6 @@
[package] [package]
name = "device-common" name = "device-common"
version = "0.1.9" version = "0.1.10"
edition = "2021" edition = "2021"
authors = ["Ryan Bae <jh.bae@anypointmedia.com>"] authors = ["Ryan Bae <jh.bae@anypointmedia.com>"]

2
README.md

@ -11,4 +11,4 @@ device-service 에서 공통으로 쓰이는 기능들의 집합
- string.rs : string 확장 기능 - string.rs : string 확장 기능
- aws/kinesis.rs : AWS Kinesis Stream 관련 기능 - aws/kinesis.rs : AWS Kinesis Stream 관련 기능
- aws/parameter_store.rs : AWS Parameter Store 관련 기능 - aws/parameter_store.rs : AWS Parameter Store 관련 기능
- aws/s3.rs : AWS S3 관련 기능] - aws/s3.rs : AWS S3 관련 기능

48
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 - added string.rs
- used tokio::sync::oncecell instead of std::sync::oncelock for async
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 0.1.5
====== ======
- fix bug for log - fix bug for log
0.1.6 0.1.4
====== ======
- changed kinesis_message(byte struct) to string(json) - fix bug for using toml library
- added 'aws' directory
- added s3.rs
0.1.7 0.1.3
====== ======
- added s3 bucket constant - remove s3 dependency(rusoto_core, rusoto_s3)
- fix some constant name(underline -> dash)
0.1.8 0.1.2
====== ======
- added campaign database information - create log directory
0.1.9 0.1.1
====== ======
- added string.rs - write test code sample
- used tokio::sync::oncecell instead of std::sync::oncelock for async
0.1.0
======
first deploy

6
src/aws/kinesis.rs

@ -12,9 +12,9 @@ async fn initialize_data() -> Arc<Client> {
let config = crate::config::get_config() let config = crate::config::get_config()
.await; .await;
let access_key_id = &config.kinesis_stream.node.access_key.clone(); let access_key_id = &config.aws.access_key.clone();
let secret_access_key = &config.kinesis_stream.node.secret_key.clone(); let secret_access_key = &config.aws.secret_key.clone();
let region = &config.kinesis_stream.node.region.clone(); let region = &config.aws.region.clone();
let credentials = Credentials::from_keys(access_key_id, secret_access_key, None); let credentials = Credentials::from_keys(access_key_id, secret_access_key, None);
let aws_config = Config::builder() let aws_config = Config::builder()

25
src/config.rs

@ -31,10 +31,14 @@ pub struct Database {
} }
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
pub struct AwsKinesisStreamDetail { pub struct Aws {
pub access_key: String, pub access_key: String,
pub secret_key: String, pub secret_key: String,
pub region: String, pub region: String,
}
#[derive(Debug, PartialEq, Serialize, Deserialize)]
pub struct AwsKinesisStreamDetail {
pub name: String, pub name: String,
pub partition_key: String, pub partition_key: String,
pub arn: String, pub arn: String,
@ -45,11 +49,18 @@ pub struct AwsKinesisStream {
pub node: AwsKinesisStreamDetail, pub node: AwsKinesisStreamDetail,
} }
#[derive(Debug, PartialEq, Serialize, Deserialize)]
pub struct AwsS3 {
pub bucket: String,
}
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
pub struct Config { pub struct Config {
pub database: Database, pub database: Database,
pub campaign_database: Database, pub campaign_database: Database,
pub rabbitmq: Rabbitmq, pub rabbitmq: Rabbitmq,
pub aws: Aws,
pub s3: AwsS3,
pub kinesis_stream: AwsKinesisStream, pub kinesis_stream: AwsKinesisStream,
} }
@ -102,11 +113,19 @@ async fn initialize_data() -> Arc<Config> {
queue: get_parameter(constants::RABBITMQ_ORCHESTRATION_QUEUE_KEY.to_string()).await, queue: get_parameter(constants::RABBITMQ_ORCHESTRATION_QUEUE_KEY.to_string()).await,
}, },
}, },
kinesis_stream: AwsKinesisStream {
node: AwsKinesisStreamDetail { aws: Aws {
access_key: crate::env::get(constants::ENV_AWS_ACCESS_KEY).expect_or_log("env aws_access_key not found"), 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"), 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"), 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 {
name: get_parameter(constants::KINESIS_PERSISTENCE_NAME_KEY.to_string()).await, name: get_parameter(constants::KINESIS_PERSISTENCE_NAME_KEY.to_string()).await,
partition_key: get_parameter(constants::KINESIS_PERSISTENCE_PARTITION_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, arn: get_parameter(constants::KINESIS_PERSISTENCE_ARN_KEY.to_string()).await,

3
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_PARTITION_KEY: &str = "/flower/device/failover/kinesis/partition-key";
pub const KINESIS_FAILOVER_ARN_KEY: &str = "/flower/device/failover/kinesis/arn"; 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_BUCKET: &str = "/flower/device/common/aws/s3/bucket";
pub const S3_PATH: &str = "/flower/device/common/s3/path";
pub const DB_HOST_KEY: &str = "/flower/device/common/db/host"; pub const DB_HOST_KEY: &str = "/flower/device/common/db/host";
pub const DB_PORT_KEY: &str = "/flower/device/common/db/port"; pub const DB_PORT_KEY: &str = "/flower/device/common/db/port";

Loading…
Cancel
Save