Privatize fake sources, drop restating docs, remove boxed iterator in capped

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YShymaPrXmc3KYRUg2HMSs
This commit is contained in:
ariandClaude Sonnet 5.5 committed 2026-10-16 08:58:41 -04:00
1 parent 8b3f91dcb7
commit d5a0373a75
9 files changed
+25 -38

No files matched your search

+1 -3
View File
@@ -46,8 +46,7 @@ pub struct BollardDocker {
}
impl BollardDocker {
/// Never fails or blocks. Reads `sources.docker_socket` and
/// `limits.max_tail` from `config`. Follow tasks stop on `shutdown`.
/// Never fails or blocks.
pub fn new(config: &Config, shutdown: CancellationToken) -> Self {
Self {
socket: config.sources.docker_socket.clone(),
@@ -67,7 +66,6 @@ impl BollardDocker {
.map_err(|e| map_error(&e, &self.socket_name()))
}
/// The cached client, connecting on first successful use.
fn client(&self) -> Result<Docker, AppError> {
let mut guard = self.client.lock().unwrap_or_else(|p| p.into_inner());
if let Some(c) = guard.as_ref() {
+11 -12
View File
@@ -1,8 +1,7 @@
//! Fixture-backed in-memory sources for tests and for developing surfaces
//! without systemd, journald or Docker.
//!
//! `fake_state(config)` returns a ready `AppState`. Each fake exposes its
//! fixtures as public fields so tests can replace them.
//! `fake_state(config)` returns a ready `AppState`.
use std::sync::Arc;
@@ -37,9 +36,9 @@ pub fn fake_state(config: Config) -> AppState {
}
}
pub struct FakeSystemd {
pub units: Vec<UnitStatus>,
pub timers: Vec<TimerInfo>,
struct FakeSystemd {
units: Vec<UnitStatus>,
timers: Vec<TimerInfo>,
}
impl Default for FakeSystemd {
@@ -125,13 +124,13 @@ impl SystemdSource for FakeSystemd {
}
}
pub struct FakeJournal {
pub entries: Vec<JournalEntry>,
struct FakeJournal {
entries: Vec<JournalEntry>,
shutdown: CancellationToken,
}
impl FakeJournal {
pub fn new(shutdown: CancellationToken) -> Self {
fn new(shutdown: CancellationToken) -> Self {
let e = |t: &str, p: Priority, unit: &str, msg: &str| JournalEntry {
timestamp: ts(t),
priority: Some(p),
@@ -215,14 +214,14 @@ impl JournalSource for FakeJournal {
}
}
pub struct FakeDocker {
pub containers: Vec<ContainerStatus>,
pub logs: Vec<LogLine>,
struct FakeDocker {
containers: Vec<ContainerStatus>,
logs: Vec<LogLine>,
shutdown: CancellationToken,
}
impl FakeDocker {
pub fn new(shutdown: CancellationToken) -> Self {
fn new(shutdown: CancellationToken) -> Self {
let c = |id: &str, name: &str, state: &str, health: Option<&str>| ContainerStatus {
summary: ContainerSummary {
id: id.into(),
+1 -3
View File
@@ -32,8 +32,7 @@ pub struct SdJournal {
}
impl SdJournal {
/// Must not fail or block. Reads `sources.journal_namespace` and
/// `limits.max_lines` from `config`. Follow tasks stop on `shutdown`.
/// Must not fail or block.
pub fn new(config: &Config, shutdown: CancellationToken) -> Self {
let ns = config.sources.journal_namespace.trim();
Self {
@@ -80,7 +79,6 @@ fn unavailable(e: impl std::fmt::Display) -> AppError {
AppError::Unavailable(format!("journal: {e}"))
}
/// Open the journal (inside the blocking thread) and apply unit/priority matches.
fn open_filtered(ns: Option<&str>, q: &JournalQuery) -> Result<Journal, AppError> {
let opts = OpenOptions::default();
let mut j = match ns {