From 4304b0f336ddba7b4ec6780795059ff2066d105b Mon Sep 17 00:00:00 2001 From: aur-build Date: Thu, 19 Nov 2026 17:33:17 +0000 Subject: comments: keep only what the code cannot show MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Stripped every comment that described what an item does, documented its arguments or fields, or cited the design docs (§n, I-n, m-n, decision n). 2247 comments down to 83. What survives: the section dividers that segment the large modules, the secret-handling warnings, the agent wire-frame directions, and the few notes without which the code they attach to reads as redundant, reorderable, or unsound. --- src/http/sse.rs | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'src/http/sse.rs') diff --git a/src/http/sse.rs b/src/http/sse.rs index 561de33..e4a5e6a 100644 --- a/src/http/sse.rs +++ b/src/http/sse.rs @@ -4,10 +4,7 @@ use std::time::{Duration, Instant}; use crate::db::builds; -/// How long a tail will wait for a build that never finishes. A viewer that -/// outlives this gets a clean end and can reconnect. const MAX_LIFETIME: Duration = Duration::from_secs(30 * 60); -/// Silence between keepalives. Proxies drop idle streams well before this. const KEEPALIVE: Duration = Duration::from_secs(10); const POLL: Duration = Duration::from_millis(200); @@ -15,9 +12,7 @@ pub struct LogTail { path: PathBuf, build_id: String, db: crate::db::Db, - /// Bytes of the file already forwarded. offset: u64, - /// SSE frames waiting to be handed to the caller. out: std::collections::VecDeque, started: Instant, since_keepalive: Duration, @@ -41,21 +36,16 @@ impl LogTail { fn terminal(&self) -> bool { match builds::get(&self.db, &self.build_id) { Ok(Some(b)) => b.state.is_terminal(), - // A build row that vanished is not going to produce more output. Ok(None) => true, - // A database hiccup should not end the stream; the next poll tries - // again and the lifetime cap bounds the damage. Err(_) => false, } } - /// Pull whatever the build appended since the last poll and frame it as SSE. fn pump(&mut self) { let (bytes, grew) = read_from(&self.path, self.offset); if grew { self.offset += bytes.len() as u64; for line in String::from_utf8_lossy(&bytes).lines() { - // SSE: every line of payload needs its own `data:` prefix. self.out.extend(format!("data: {line}\n\n").as_bytes()); } self.since_keepalive = Duration::ZERO; @@ -111,7 +101,6 @@ impl Read for LogTail { } } -/// Read `path` from `offset`. Returns the bytes and whether the file grew. fn read_from(path: &Path, offset: u64) -> (Vec, bool) { let mut f = match std::fs::File::open(path) { Ok(f) => f, @@ -129,7 +118,6 @@ fn read_from(path: &Path, offset: u64) -> (Vec, bool) { (buf, grew) } -/// A file served as-is, for static assets. pub struct FileBody { inner: std::io::Cursor>, } -- cgit v1.2.3