pub struct Reading {
pub schema: u32,
pub pid: Option<u32>,
pub started_at: Option<Timestamp>,
pub updated_at: Option<Timestamp>,
pub idle: bool,
pub current: Vec<Current>,
pub completed: u64,
pub polls: u64,
}Expand description
The daemon’s published state, read permissively.
This mirrors Status, but is a separate declaration on purpose: every
field defaults, so a status file from an older or newer magi still yields
a usable reading — one this build has never heard of — instead of a parse
error that hides the daemon entirely.
Fields§
§schema: u32Format version the daemon claims.
pid: Option<u32>Daemon process id, for an operator who wants to stop it.
started_at: Option<Timestamp>When that process started.
updated_at: Option<Timestamp>Last heartbeat. Absent means the file is unusable, hence not running.
idle: boolTrue when the queue had nothing runnable at the last poll.
current: Vec<Current>What the daemon is working on. Empty means idle; more than one entry means more than one run is in flight at once.
deserialize_with rather than the plain derive: a daemon started
before this field became a list is still out there writing the old
shape — a single {"task":...,"run":...} object, or its absence —
on every heartbeat until it is restarted, and a live process reading
that file during the rollout must still see it as running rather than
as absent. A bare type change here would fail the whole struct’s
deserialization on a type mismatch, defeating the permissiveness this
type exists for.
completed: u64Tasks this daemon process has finished.
polls: u64Queue polls this daemon process has made.
Implementations§
Source§impl Reading
impl Reading
Sourcepub fn age_secs(&self, now: Timestamp) -> Option<i64>
pub fn age_secs(&self, now: Timestamp) -> Option<i64>
Seconds since the last heartbeat, or None when there has never been
one.
Sourcepub fn running(&self, now: Timestamp) -> bool
pub fn running(&self, now: Timestamp) -> bool
Whether the loop counts as running: a heartbeat no older than
STALE_SECS. The alternative is a reader that claims a task is in
progress hours after the daemon that owned it was killed.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Reading
impl<'de> Deserialize<'de> for Reading
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for Reading
impl RefUnwindSafe for Reading
impl Send for Reading
impl Sync for Reading
impl Unpin for Reading
impl UnsafeUnpin for Reading
impl UnwindSafe for Reading
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more