pub struct HealthMonitor {
block_id: String,
inner: Mutex<HealthMonitorInner>,
broker: Option<Arc<Broker>>,
}Expand description
Per-block agent health monitor.
Tracks output activity and error rates, computes health state, and emits WPS events on state transitions.
Fields§
§block_id: String§inner: Mutex<HealthMonitorInner>§broker: Option<Arc<Broker>>Implementations§
Source§impl HealthMonitor
impl HealthMonitor
Sourceconst STALL_SECS: u64 = 30
const STALL_SECS: u64 = 30
Stall threshold: no meaningful output for 30s during active turn.
Sourceconst ERROR_WINDOW_SECS: u64 = 300
const ERROR_WINDOW_SECS: u64 = 300
Error window duration.
Sourceconst DEGRADED_TRANSIENT_THRESHOLD: usize = 5
const DEGRADED_TRANSIENT_THRESHOLD: usize = 5
Transient error count threshold for degraded.
pub fn new(block_id: String, broker: Option<Arc<Broker>>) -> Self
Sourcepub fn set_active_turn(&self, active: bool)
pub fn set_active_turn(&self, active: bool)
Called when a new turn starts (subprocess spawned).
Sourcepub fn set_exited(&self, exit_code: i32)
pub fn set_exited(&self, exit_code: i32)
Called when the subprocess exits.
Sourcepub fn record_output(&self, meaningful: bool)
pub fn record_output(&self, meaningful: bool)
Called for each output line from stdout.
meaningful is false for rate_limit_event and similar non-progress events.
Sourcepub fn record_error(&self, class: ErrorClass, message: String)
pub fn record_error(&self, class: ErrorClass, message: String)
Called when an error is detected in the output stream.
Sourcepub fn is_active_turn(&self) -> bool
pub fn is_active_turn(&self) -> bool
Whether there’s an active turn in progress.
Sourcefn evaluate_and_transition(&self)
fn evaluate_and_transition(&self)
Compute current health and emit event if it changed.
Sourcefn compute_health(inner: &HealthMonitorInner) -> AgentHealth
fn compute_health(inner: &HealthMonitorInner) -> AgentHealth
Composite health computation.
Sourcefn make_detail(inner: &HealthMonitorInner, health: &AgentHealth) -> String
fn make_detail(inner: &HealthMonitorInner, health: &AgentHealth) -> String
Generate human-readable detail string.
Sourcefn publish_health(&self, event: AgentHealthEvent)
fn publish_health(&self, event: AgentHealthEvent)
Publish health event via WPS broker.
Auto Trait Implementations§
impl !Freeze for HealthMonitor
impl RefUnwindSafe for HealthMonitor
impl Send for HealthMonitor
impl Sync for HealthMonitor
impl Unpin for HealthMonitor
impl UnwindSafe for HealthMonitor
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
Mutably borrows from an owned value. Read more
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.