Add the throttle flag
This commit is contained in:
parent
9106e23d61
commit
03e357fd40
2 changed files with 11 additions and 0 deletions
|
|
@ -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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue