|
Common System 0.2.0
Common interfaces and patterns for system integration
|
Aggregates multiple health checks into a single check. More...
#include <composite_health_check.h>


Public Member Functions | |
| composite_health_check (std::string name, health_check_type type=health_check_type::custom, bool critical=true) | |
| Construct a composite health check. | |
| std::string | get_name () const override |
| Get the unique name of this health check. | |
| health_check_type | get_type () const override |
| Get the type of this health check. | |
| bool | is_critical () const override |
| Check if this health check is critical. | |
| health_check_result | check () override |
| Execute all child health checks and aggregate results. | |
| void | add_check (std::shared_ptr< health_check > check) |
| Add a child health check. | |
| bool | remove_check (const std::string &name) |
| Remove a child health check by name. | |
| std::size_t | size () const |
| Get the number of child checks. | |
| bool | empty () const |
| Check if this composite has no child checks. | |
| void | clear () |
| Clear all child checks. | |
| std::vector< std::string > | get_check_names () const |
| Get all child check names. | |
Public Member Functions inherited from kcenon::common::interfaces::health_check | |
| health_check ()=default | |
| virtual | ~health_check ()=default |
| health_check (const health_check &)=delete | |
| health_check & | operator= (const health_check &)=delete |
| health_check (health_check &&)=delete | |
| health_check & | operator= (health_check &&)=delete |
| virtual std::chrono::milliseconds | get_timeout () const |
| Get timeout duration for this health check. | |
Private Attributes | |
| std::string | name_ |
| health_check_type | type_ |
| bool | critical_ |
| std::vector< std::shared_ptr< health_check > > | checks_ |
| std::mutex | mutex_ |
Aggregates multiple health checks into a single check.
This class implements the Composite pattern for health checks, allowing multiple checks to be grouped and executed together. The overall health status is determined by the worst status among all child checks.
Example usage:
Definition at line 43 of file composite_health_check.h.
|
inlineexplicit |
Construct a composite health check.
| name | Name for this composite check |
| type | Health check type (default: custom) |
| critical | Whether this composite is critical (default: true) |
Definition at line 51 of file composite_health_check.h.
|
inline |
Add a child health check.
| check | Health check to add |
Definition at line 139 of file composite_health_check.h.
References check(), checks_, and mutex_.

|
inlineoverridevirtual |
Execute all child health checks and aggregate results.
The overall status is determined as follows:
Implements kcenon::common::interfaces::health_check.
Definition at line 73 of file composite_health_check.h.
References check(), kcenon::common::interfaces::health_check_result::check_duration, checks_, kcenon::common::interfaces::degraded, kcenon::common::interfaces::healthy, kcenon::common::interfaces::health_check_result::message, kcenon::common::interfaces::health_check_result::metadata, mutex_, kcenon::common::interfaces::health_check_result::status, kcenon::common::interfaces::unhealthy, and kcenon::common::interfaces::unknown.
Referenced by add_check(), check(), get_check_names(), and remove_check().


|
inline |
|
inlinenodiscard |
|
inlinenodiscard |
Get all child check names.
Definition at line 195 of file composite_health_check.h.
References check(), checks_, and mutex_.

|
inlinenodiscardoverridevirtual |
Get the unique name of this health check.
Implements kcenon::common::interfaces::health_check.
Definition at line 57 of file composite_health_check.h.
References name_.
|
inlinenodiscardoverridevirtual |
Get the type of this health check.
Implements kcenon::common::interfaces::health_check.
Definition at line 59 of file composite_health_check.h.
References type_.
|
inlinenodiscardoverridevirtual |
Check if this health check is critical.
Critical health checks affect the overall system health status. Non-critical checks are reported but don't impact system health.
Implements kcenon::common::interfaces::health_check.
Definition at line 61 of file composite_health_check.h.
References critical_.
|
inline |
Remove a child health check by name.
| name | Name of the check to remove |
Definition at line 152 of file composite_health_check.h.
References check(), checks_, and mutex_.

|
inlinenodiscard |
|
private |
Definition at line 209 of file composite_health_check.h.
Referenced by add_check(), check(), clear(), empty(), get_check_names(), remove_check(), and size().
|
private |
Definition at line 208 of file composite_health_check.h.
Referenced by is_critical().
|
mutableprivate |
Definition at line 210 of file composite_health_check.h.
Referenced by add_check(), check(), clear(), empty(), get_check_names(), remove_check(), and size().
|
private |
Definition at line 206 of file composite_health_check.h.
Referenced by get_name().
|
private |
Definition at line 207 of file composite_health_check.h.
Referenced by get_type().