-
Notifications
You must be signed in to change notification settings - Fork 257
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(3133 ): suggest users to update the rc files if it's are not upd…
…ated (#3136)
- Loading branch information
Showing
3 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ mod helpers; | |
mod init; | ||
pub mod run; | ||
mod start; | ||
mod validate_rc; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
use std::path::Path; | ||
|
||
use super::helpers::{TAILCALL_RC, TAILCALL_RC_SCHEMA}; | ||
use crate::core::runtime::TargetRuntime; | ||
|
||
pub async fn validate_rc_config_files(runtime: TargetRuntime, file_paths: &[String]) { | ||
// base config files. | ||
let tailcallrc = include_str!("../../../generated/.tailcallrc.graphql"); | ||
let tailcallrc_json = include_str!("../../../generated/.tailcallrc.schema.json"); | ||
|
||
// Define the config files to check with their base contents | ||
let rc_config_files = vec![ | ||
(TAILCALL_RC, tailcallrc), | ||
(TAILCALL_RC_SCHEMA, tailcallrc_json), | ||
]; | ||
|
||
for path in file_paths { | ||
let parent_dir = match Path::new(path).parent() { | ||
Some(dir) => dir, | ||
None => continue, | ||
}; | ||
|
||
let mut outdated_files = Vec::with_capacity(rc_config_files.len()); | ||
|
||
for (file_name, base_content) in &rc_config_files { | ||
let config_path = parent_dir.join(file_name); | ||
if config_path.exists() { | ||
if let Ok(content) = runtime.file.read(&config_path.to_string_lossy()).await { | ||
if &content != base_content { | ||
// file content not same. | ||
outdated_files.push(file_name.to_owned()); | ||
} | ||
} else { | ||
// unable to read file. | ||
outdated_files.push(file_name.to_owned()); | ||
} | ||
} | ||
} | ||
|
||
if !outdated_files.is_empty() { | ||
let outdated_files = outdated_files.join(", "); | ||
tracing::warn!( | ||
"[{}] {} outdated, reinitialize using tailcall init.", | ||
outdated_files, | ||
pluralizer::pluralize("is", outdated_files.len() as isize, false) | ||
); | ||
} | ||
} | ||
} |
847d1da
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running 30s test @ http://localhost:8000/graphql
4 threads and 100 connections
741218 requests in 30.02s, 3.72GB read
Requests/sec: 24692.02
Transfer/sec: 126.74MB