pub struct StatusEngine { /* private fields */ }Expand description
Periodic status collection from pluggable sources.
Implementations§
Source§impl StatusEngine
impl StatusEngine
pub fn new() -> Self
Sourcepub fn register_source(&self, source: Arc<dyn StatusSource>)
pub fn register_source(&self, source: Arc<dyn StatusSource>)
Register a status source.
Sourcepub fn unregister_source(&self, name: &str) -> bool
pub fn unregister_source(&self, name: &str) -> bool
Unregister all status sources with the given name.
Returns true if at least one source was removed. The name disappears
from the collected status on the next StatusEngine::collect run
(collect rebuilds the status map from the registered sources on every
call). Enables components that are rebuilt at runtime to replace their
status nodes without leaking stale registrations.
Sourcepub fn collect(&self) -> Value
pub fn collect(&self) -> Value
Poll all sources whose refresh interval has elapsed and return collected status.
Sourcepub fn get_last_status(&self) -> Value
pub fn get_last_status(&self) -> Value
Return the most recently collected status.
Sourcepub fn start(&self, shutdown: &ShutdownHandler)
👎Deprecated: was a no-op; use start_background() or run_status_loop()
pub fn start(&self, shutdown: &ShutdownHandler)
Start a background collection thread.
Historic accident: this method never spawned anything (it cannot —
the loop needs an Arc<Self>). Use StatusEngine::start_background
or [run_status_loop].
Sourcepub fn start_background(self: Arc<Self>, shutdown: &ShutdownHandler)
pub fn start_background(self: Arc<Self>, shutdown: &ShutdownHandler)
Start the background collection loop.
Collects immediately, then every min(refresh_interval) of the
registered sources (at least 5 s). The thread ends on shutdown or
after stop.
Sourcepub fn start_background_supervised(
self: Arc<Self>,
shutdown: &ShutdownHandler,
heartbeat: Option<(Arc<HeartbeatEngine>, String)>,
)
pub fn start_background_supervised( self: Arc<Self>, shutdown: &ShutdownHandler, heartbeat: Option<(Arc<HeartbeatEngine>, String)>, )
Like start_background, but reports to a
HeartbeatEngine on every collection.
Consumers whose architecture requires every long-running thread to be
watchdog-supervised need this: without it, a wedged collector is silent —
and a silent collector means the fleet snapshot freezes on its last state
while the machine keeps running. Pass the engine and the id to register
under; the collector registers itself with a timeout of 4 × its
collection interval (a missed beat then means “wedged”, not “slow”).