|
Common System 0.2.0
Common interfaces and patterns for system integration
|
Health check implementation using a lambda function. More...
#include <health_check.h>


Public Types | |
| using | check_function = std::function<health_check_result()> |
Public Member Functions | |
| lambda_health_check (std::string name, health_check_type type, check_function check_fn, bool critical=true, std::chrono::milliseconds timeout=std::chrono::milliseconds{5000}) | |
| Construct a lambda 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. | |
| health_check_result | check () override |
| Perform the health check. | |
| std::chrono::milliseconds | get_timeout () const override |
| Get timeout duration for this health check. | |
| bool | is_critical () const override |
| Check if this health check is critical. | |
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 |
Private Attributes | |
| std::string | name_ |
| health_check_type | type_ |
| check_function | check_fn_ |
| bool | critical_ |
| std::chrono::milliseconds | timeout_ |
Health check implementation using a lambda function.
This class allows creating health checks from lambda functions, useful for simple checks that don't require a full class hierarchy.
Example usage:
Definition at line 173 of file health_check.h.
| using kcenon::common::interfaces::lambda_health_check::check_function = std::function<health_check_result()> |
Definition at line 175 of file health_check.h.
|
inline |
Construct a lambda health check.
| name | Health check name |
| type | Health check type |
| check_fn | Function to execute for health check |
| critical | Whether this check is critical (default: true) |
| timeout | Check timeout (default: 5 seconds) |
Definition at line 185 of file health_check.h.
|
inlineoverridevirtual |
Perform the health check.
Implements kcenon::common::interfaces::health_check.
Definition at line 200 of file health_check.h.
References check_fn_, kcenon::common::interfaces::health_check_result::message, kcenon::common::interfaces::health_check_result::status, and kcenon::common::interfaces::unknown.
|
inlinenodiscardoverridevirtual |
Get the unique name of this health check.
Implements kcenon::common::interfaces::health_check.
Definition at line 196 of file health_check.h.
References name_.
|
inlinenodiscardoverridevirtual |
Get timeout duration for this health check.
Implements kcenon::common::interfaces::health_check.
Definition at line 210 of file health_check.h.
References timeout_.
|
inlinenodiscardoverridevirtual |
Get the type of this health check.
Implements kcenon::common::interfaces::health_check.
Definition at line 198 of file 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 212 of file health_check.h.
References critical_.
|
private |
Definition at line 217 of file health_check.h.
Referenced by check().
|
private |
Definition at line 218 of file health_check.h.
Referenced by is_critical().
|
private |
Definition at line 215 of file health_check.h.
Referenced by get_name().
|
private |
Definition at line 219 of file health_check.h.
Referenced by get_timeout().
|
private |
Definition at line 216 of file health_check.h.
Referenced by get_type().