Health
This module implements infrastructure for health management.
- class HealthModel(health_changed_callback, **kwargs)
A simple health model the supports.
HealthState.UNKNOWN – when communication with the component is not established.
HealthState.FAILED – when the component has faulted
HealthState.OK – when neither of the above conditions holds.
This health model does not support HealthState.DEGRADED. It is up to subclasses to implement support for DEGRADED if required.
- __init__(health_changed_callback, **kwargs)
Initialise a new instance.
- component_fault(fault)
Handle a component experiencing or recovering from a fault.
This is a callback hook that is called when the component goes into or out of FAULT state.
- evaluate_health()
Re-evaluate the health state.
This method contains the logic for evaluating the health. It is this method that should be extended by subclasses in order to define how health is evaluated by their particular device.
- Return type:
- Returns:
the new health state.
- property health_params: dict[str, float]
Get the thresholds for health rules.
- Returns:
the thresholds for health rules
- property health_state: HealthState
Return the health state.
- Returns:
the health state.
- is_communicating(communicating)
Handle change in communication with the component.
- update_health()
Update health state.
This method calls the :py:meth:
evaluate_health
method to figure out what the new health state should be, and then updates thehealth_state
attribute, calling the callback if required.- Return type: