This commit is contained in:
Hugh Kaznowski
2026-09-05 12:23:46 +01:00
parent 818f8d09ea
commit 68548911bc
34 changed files with 3262 additions and 4 deletions
+25
View File
@@ -0,0 +1,25 @@
use crate::engine::{EngineMessage, IngestedLine};
use crate::timestamp::Timestamp;
use tokio::io::{AsyncBufReadExt, BufReader};
use tokio::sync::mpsc;
/// Reads stdin line by line, sequences and timestamps each line, and forwards it
/// to the engine task.
pub async fn run(engine: mpsc::Sender<EngineMessage>) {
let stdin = tokio::io::stdin();
let mut lines = BufReader::new(stdin).lines();
let mut sequence: u64 = 0;
while let Ok(Some(text)) = lines.next_line().await {
let line = IngestedLine {
sequence,
timestamp: Timestamp::now(),
text,
};
sequence += 1;
if engine.send(EngineMessage::Ingest(line)).await.is_err() {
break;
}
}
}