From 2f38ee0fc42a4b3b3f8ce73b2b51a00ec86d8334 Mon Sep 17 00:00:00 2001 From: Matt Straathof Date: Wed, 10 Apr 2024 18:39:28 -0700 Subject: [PATCH 1/2] fix: speed up cloud linter command --- .gitignore | 2 ++ momento/src/commands/cloud_linter/linter_cli.rs | 16 ++++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index dcc6f397..baa04b3a 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,5 @@ client-cli.iml bin/ momento.exe obj/ +*.gz + diff --git a/momento/src/commands/cloud_linter/linter_cli.rs b/momento/src/commands/cloud_linter/linter_cli.rs index ae9a8f02..dfd5bc7b 100644 --- a/momento/src/commands/cloud_linter/linter_cli.rs +++ b/momento/src/commands/cloud_linter/linter_cli.rs @@ -28,17 +28,21 @@ pub async fn run_cloud_linter(region: String) -> Result<(), CliError> { let output_file_path = "linter_results.json.gz"; check_output_is_writable(output_file_path).await?; - let quota = - Quota::per_second(core::num::NonZeroU32::new(1).expect("should create non-zero quota")); - let limiter = Arc::new(RateLimiter::direct(quota)); + let fast_quota = + Quota::per_second(core::num::NonZeroU32::new(10).expect("should create non-zero fast_quota")); + let fast_limiter = Arc::new(RateLimiter::direct(fast_quota)); - let mut resources = get_ddb_resources(&config, Arc::clone(&limiter)).await?; + let slow_quota = + Quota::per_second(core::num::NonZeroU32::new(1).expect("should create non-zero slow_quota")); + let slow_limiter = Arc::new(RateLimiter::direct(slow_quota)); + + let mut resources = get_ddb_resources(&config, Arc::clone(&slow_limiter)).await?; let mut elasticache_resources = - get_elasticache_resources(&config, Arc::clone(&limiter)).await?; + get_elasticache_resources(&config, Arc::clone(&fast_limiter)).await?; resources.append(&mut elasticache_resources); - let resources = append_metrics_to_resources(&config, Arc::clone(&limiter), resources).await?; + let resources = append_metrics_to_resources(&config, Arc::clone(&fast_limiter), resources).await?; let data_format = DataFormat { resources }; From 09af9f1f269964905d8a0475fc3b8b9feb37774e Mon Sep 17 00:00:00 2001 From: Matt Straathof Date: Wed, 10 Apr 2024 18:40:00 -0700 Subject: [PATCH 2/2] fix: clippy --- momento/src/commands/cloud_linter/linter_cli.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/momento/src/commands/cloud_linter/linter_cli.rs b/momento/src/commands/cloud_linter/linter_cli.rs index dfd5bc7b..42c3672d 100644 --- a/momento/src/commands/cloud_linter/linter_cli.rs +++ b/momento/src/commands/cloud_linter/linter_cli.rs @@ -28,12 +28,14 @@ pub async fn run_cloud_linter(region: String) -> Result<(), CliError> { let output_file_path = "linter_results.json.gz"; check_output_is_writable(output_file_path).await?; - let fast_quota = - Quota::per_second(core::num::NonZeroU32::new(10).expect("should create non-zero fast_quota")); + let fast_quota = Quota::per_second( + core::num::NonZeroU32::new(10).expect("should create non-zero fast_quota"), + ); let fast_limiter = Arc::new(RateLimiter::direct(fast_quota)); - let slow_quota = - Quota::per_second(core::num::NonZeroU32::new(1).expect("should create non-zero slow_quota")); + let slow_quota = Quota::per_second( + core::num::NonZeroU32::new(1).expect("should create non-zero slow_quota"), + ); let slow_limiter = Arc::new(RateLimiter::direct(slow_quota)); let mut resources = get_ddb_resources(&config, Arc::clone(&slow_limiter)).await?; @@ -42,7 +44,8 @@ pub async fn run_cloud_linter(region: String) -> Result<(), CliError> { get_elasticache_resources(&config, Arc::clone(&fast_limiter)).await?; resources.append(&mut elasticache_resources); - let resources = append_metrics_to_resources(&config, Arc::clone(&fast_limiter), resources).await?; + let resources = + append_metrics_to_resources(&config, Arc::clone(&fast_limiter), resources).await?; let data_format = DataFormat { resources };