Merge branch 'throttle-flag' into 'main'
Add the throttle flag See merge request x433485/minisql!32
This commit is contained in:
commit
b87ff160d2
3 changed files with 15 additions and 1 deletions
|
|
@ -17,7 +17,10 @@ pub fn parse_identifier(input: &str) -> IResult<&str, &str> {
|
||||||
let (_, first) = peek(anychar)(input)?;
|
let (_, first) = peek(anychar)(input)?;
|
||||||
if first.is_alphabetic() || first == '_' {
|
if first.is_alphabetic() || first == '_' {
|
||||||
take_while(|c: char| {
|
take_while(|c: char| {
|
||||||
is_alphanumeric(c as u8) || c == '_'
|
match c {
|
||||||
|
'a'..='z' | 'A'..='Z' | '_' | '0'..='9' => true,
|
||||||
|
_ => false
|
||||||
|
}
|
||||||
})(input)
|
})(input)
|
||||||
} else {
|
} else {
|
||||||
Err(nom::Err::Error(make_error(
|
Err(nom::Err::Error(make_error(
|
||||||
|
|
|
||||||
|
|
@ -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