diff options
| author | aur-build <aur-build@localhost> | 2026-11-19 17:33:17 +0000 |
|---|---|---|
| committer | aur-build <aur-build@localhost> | 2026-11-19 17:33:17 +0000 |
| commit | 4304b0f336ddba7b4ec6780795059ff2066d105b (patch) | |
| tree | 10edea744a1c2bf3fc363b4dc7f64abac8b1a0d3 /src/http/sse.rs | |
| parent | e757979f1a2afdbe7146066345bb9acd19d3b151 (diff) | |
| download | aur-build-4304b0f336ddba7b4ec6780795059ff2066d105b.tar.gz aur-build-4304b0f336ddba7b4ec6780795059ff2066d105b.zip | |
comments: keep only what the code cannot show
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.
Diffstat (limited to 'src/http/sse.rs')
| -rw-r--r-- | src/http/sse.rs | 12 |
1 files changed, 0 insertions, 12 deletions
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<u8>, 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<u8>, 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<u8>, bool) { (buf, grew) } -/// A file served as-is, for static assets. pub struct FileBody { inner: std::io::Cursor<Vec<u8>>, } |
