brinkhaustools

Struct StatusEngine

Source
pub struct StatusEngine { /* private fields */ }
Expand description

Periodic status collection from pluggable sources.

Implementations§

Source§

impl StatusEngine

Source

pub fn new() -> Self

Source

pub fn register_source(&self, source: Arc<dyn StatusSource>)

Register a status source.

Source

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.

Source

pub fn collect(&self) -> Value

Poll all sources whose refresh interval has elapsed and return collected status.

Source

pub fn get_last_status(&self) -> Value

Return the most recently collected status.

Source

pub fn start(&self, shutdown: &ShutdownHandler)

👎Deprecated: was a no-op; use start_background() or run_status_loop()

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].

Source

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.

Source

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”).

Source

pub fn stop(&self)

Stop the background collection thread (takes effect within one collection interval).

Trait Implementations§

Source§

impl Default for StatusEngine

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more