#[non_exhaustive]pub struct ProcessInfo {Show 16 fields
pub id: u32,
pub name: String,
pub status: ProcStatus,
pub pid: Option<u32>,
pub restarts: u32,
pub uptime_ms: u64,
pub fold: Option<String>,
pub out_file: Option<String>,
pub err_file: Option<String>,
pub cpu_percent: Option<f32>,
pub memory_bytes: Option<u64>,
pub dog: Option<DogSource>,
pub lambs: Option<Vec<Lamb>>,
pub last_exit: Option<ExitInfo>,
pub smit: Option<String>,
pub instance: Option<u32>,
}Expand description
Snapshot of one sheep for listings and events
#[non_exhaustive]: this struct grows fields over time with no hand-edit
sweep needed across OUT-OF-TREE callers — it forbids a struct literal
outside this crate, not inside it. sample_info() and
ProcessInfoBuilder both still name every field and both still need
updating the day a field is added; what the attribute buys is that
nothing downstream does. deferred.md’s own ProcessInfo entry defers
SPLITTING it into several smaller types, not growing it — this attribute
plus ProcessInfo::builder is “deliberately the opposite of forcing
the split early,” which is what makes a field like last_exit cheap to
add for a concrete operator need, not a reason to withhold one. Use
ProcessInfo::builder to construct one; the fields stay pub, so
reading them and assigning to them are both unchanged.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.id: u32Stable numeric id
name: StringSheep name
status: ProcStatusLifecycle status
pid: Option<u32>OS pid while running
restarts: u32Restart count since registration
uptime_ms: u64Milliseconds since last successful start
fold: Option<String>Fold membership
out_file: Option<String>Resolved stdout log path: the app’s explicit
AppConfig::out_file when it set one, else the daemon-derived
default. None only when the peer daemon predates this field.
err_file: Option<String>Resolved stderr log path, resolved exactly as Self::out_file
cpu_percent: Option<f32>Tree CPU as a percentage of one core, over the window since the
daemon’s last periodic sample. None when the sheep is not running,
when it has been up for less than one sampling window, or when the
peer daemon predates this field — all three of which a reader
renders as unknown, never as zero.
A value over 100 is a tree using more than one core, not a bug.
memory_bytes: Option<u64>Tree resident set size in bytes, current as of the reply. None
under the same three conditions as Self::cpu_percent, minus the
window one — memory needs no baseline.
dog: Option<DogSource>Set when this entry is a dog, naming where the dog came from;
None for a sheep.
Unlike Self::cpu_percent, None here does not need to enumerate
three cases. A daemon built before dogs existed has none, so “not a
dog” is the true answer whether this peer predates the field or the
entry is genuinely a sheep — there is no resource-usage-style claim
a stale zero could get wrong. Do not “fix” this into three cases.
lambs: Option<Vec<Lamb>>The processes the OS reports as descendants of this sheep, or None
when this reply did not walk for them.
None covers two cases and is deliberately not a third: this reply is
not a Describe (only Describe walks — the walk costs a second pass
over the machine’s process table, and a flock listing is the thing an
operator leaves running in a loop), or the peer daemon predates the
field. Some(vec![]) is the third case, and the one that means what it
looks like: walked, and this sheep has no children.
Read Lamb’s own doc before rendering this. The list is a parent-pid
walk and is NOT the set of processes a stop kills; any output built from
it has to say so where the operator will see it.
last_exit: Option<ExitInfo>How this sheep’s process most recently stopped existing under this
daemon. None while it has never exited under this daemon — either
it has not been started yet, or it is still on its very first run —
and also when the peer daemon predates this field, the same skew
rule Self::out_file documents for itself.
Sticky across a respawn, deliberately: this is the daemon’s answer
to “why did it last stop”, not “is it stopped right now” — status
and pid already answer that, and a sheep back Online after a
crash still has a true story to tell about the crash that restarted
it. It updates only on the next exit, never cleared by one starting
back up.
smit: Option<String>The marker a dog has asked to have painted beside this sheep, or
None when no dog has painted one — which also covers a peer daemon
that predates the field, the same skew rule Self::out_file
documents for itself.
A String rather than a Smit, deliberately: a client decoding a
listing from a daemon that already validated the text should not have
to re-run the parser, and ProcessInfo is a report rather than an
input. The validation that makes this safe to print happened at the
daemon’s ingress — see Smit for why there and not at the renderer.
Every instance of a name shows the same marker: smits are keyed by sheep name, not by instance id.
instance: Option<u32>Which instance slot of its app this sheep occupies, counting from 0.
None when the peer daemon predates the field, the same skew rule
Self::out_file documents for itself. Deliberately not a bare
u32 defaulted to 0: an app stocked to four instances would then
report four rows all claiming slot 0, which is the silently-wrong
zero Self::dog warns against. A reader that finds None should
render exactly what it rendered before this field existed.
Implementations§
Source§impl ProcessInfo
impl ProcessInfo
Sourcepub fn builder(
id: u32,
name: impl Into<String>,
status: ProcStatus,
) -> ProcessInfoBuilder
pub fn builder( id: u32, name: impl Into<String>, status: ProcStatus, ) -> ProcessInfoBuilder
Starts a builder for one sheep’s row.
The three required arguments are the three fields no row can omit and
no reader can default: which sheep this is, what it is called, and
what state it is in. Everything else is optional, derived, or
meaningfully absent, which is exactly the shape a builder is for —
a nine-argument new would put Option<String>, Option<String>, Option<f32>, Option<u64> next to each other at every call site and
invite a silent transposition the type system could not catch.
No #[must_use] here: ProcessInfoBuilder already carries one,
which clippy’s double_must_use lint treats as covering this
function’s return too.
Trait Implementations§
Source§impl Clone for ProcessInfo
impl Clone for ProcessInfo
Source§fn clone(&self) -> ProcessInfo
fn clone(&self) -> ProcessInfo
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more