diff --git a/server/src/config.rs b/server/src/config.rs index 2f15935..efdb3c4 100644 --- a/server/src/config.rs +++ b/server/src/config.rs @@ -18,6 +18,8 @@ pub struct Configuration { port: u16, #[arg(short, long, help = "Path to the data file")] file: PathBuf, + #[arg(short, long, help = "Delay between rows in milliseconds")] + throttle: Option, } impl Configuration { @@ -30,4 +32,9 @@ impl Configuration { pub fn get_file_path(&self) -> &PathBuf { &self.file } + + #[inline] + pub fn get_throttle(&self) -> Option { + self.throttle + } } diff --git a/server/src/main.rs b/server/src/main.rs index e54677e..74d35e4 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -223,6 +223,10 @@ where token.reset(); break; } + if let Some(throttle) = config.get_throttle() { + writer.flush().await?; + tokio::time::sleep(tokio::time::Duration::from_millis(throttle)).await; + } } writer