Skip to content

Commit

Permalink
Chain stream instead of merge
Browse files Browse the repository at this point in the history
  • Loading branch information
RDruon committed Aug 20, 2024
1 parent bc281a3 commit fd007df
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lustrefs-exporter/src/jobstats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ pub fn jobstats_stream<R: BufRead + std::marker::Send + 'static>(
let x = tokio::task::spawn_blocking(move || {
let mut state = State::Empty;

// Send a new line to avoid printing at the same level as the previous stats
_ = tx.blocking_send('\n'.to_compact_string());
// Send a new line to make sure we are printing stats with a separating empty line
_ = tx.blocking_send("\n".to_compact_string());

for line in f.lines() {
let r = handle_line(&tx, line.map_err(Error::Io), state);
Expand Down
2 changes: 1 addition & 1 deletion lustrefs-exporter/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ async fn scrape(Query(params): Query<Params>) -> Result<Response<Body>, Error> {

let body = if let Some(stream) = jobstats {
let merged =
tokio_stream::StreamExt::merge(stream, tokio_stream::once(Ok(lustre_stats.into())));
tokio_stream::StreamExt::chain(tokio_stream::once(Ok(lustre_stats.into())), stream);

Body::from_stream(merged)
} else {
Expand Down

0 comments on commit fd007df

Please sign in to comment.