fix: Don't attempt to write 0 lines

pull/24376/head
Carol (Nichols || Goulding) 2022-09-29 13:07:14 -04:00
parent 8187b003c3
commit 79afb6ef54
No known key found for this signature in database
GPG Key ID: E907EE5A736F87D4
1 changed files with 9 additions and 4 deletions

View File

@ -148,11 +148,12 @@ impl Agent {
let mut streams = Vec::with_capacity(batch_size);
for _ in 0..batch_size {
let mut s = self.generate().await?;
if s.is_empty() {
if self.finished {
break;
} else {
let mut s = self.generate().await?;
streams.append(&mut s);
}
streams.append(&mut s);
}
for s in &streams {
@ -160,6 +161,10 @@ impl Agent {
total_points += s.line_count();
}
if points_this_batch == 0 && self.finished {
break;
}
points_writer
.write_points(streams.into_iter().flatten())
.await
@ -187,7 +192,7 @@ impl Agent {
/// Generate data points from the configuration in this agent.
pub async fn generate(&mut self) -> Result<Vec<MeasurementLineIterator>> {
debug!(
"[agent {}] generate more? {} current: {}, end: {}",
"[agent {}] finished? {} current: {}, end: {}",
self.id, self.finished, self.current_datetime, self.end_datetime
);