Add the throttle flag

This commit is contained in:
Maxim Svistunov 2024-02-05 13:23:46 +01:00
parent 9106e23d61
commit 03e357fd40
2 changed files with 11 additions and 0 deletions

View file

@ -18,6 +18,8 @@ pub struct Configuration {
port: u16, port: u16,
#[arg(short, long, help = "Path to the data file")] #[arg(short, long, help = "Path to the data file")]
file: PathBuf, file: PathBuf,
#[arg(short, long, help = "Delay between rows in milliseconds")]
throttle: Option<u64>,
} }
impl Configuration { impl Configuration {
@ -30,4 +32,9 @@ impl Configuration {
pub fn get_file_path(&self) -> &PathBuf { pub fn get_file_path(&self) -> &PathBuf {
&self.file &self.file
} }
#[inline]
pub fn get_throttle(&self) -> Option<u64> {
self.throttle
}
} }

View file

@ -223,6 +223,10 @@ where
token.reset(); token.reset();
break; break;
} }
if let Some(throttle) = config.get_throttle() {
writer.flush().await?;
tokio::time::sleep(tokio::time::Duration::from_millis(throttle)).await;
}
} }
writer writer