|
Monitoring System 0.1.0
System resource monitoring with pluggable collectors and alerting
|
Directed acyclic graph for health check dependencies. More...
#include <health_monitor.h>

Public Member Functions | |
| common::Result< bool > | add_node (const std::string &name, std::shared_ptr< health_check > check) |
| Add a health check node to the graph. | |
| common::Result< bool > | add_dependency (const std::string &dependent, const std::string &dependency) |
| Add a dependency edge: dependent depends on dependency. | |
| std::vector< std::string > | get_dependencies (const std::string &name) const |
| Get the direct dependencies of a node. | |
| std::vector< std::string > | get_dependents (const std::string &name) const |
| Get the nodes that directly depend on the given node. | |
| bool | would_create_cycle (const std::string &from, const std::string &to) const |
| Check whether adding an edge from -> to would create a cycle. | |
| std::vector< std::string > | topological_sort () const |
| Compute a topological ordering of all nodes. | |
| health_check_result | check_with_dependencies (const std::string &name) |
| Execute a health check after verifying all its dependencies are healthy. | |
| std::vector< std::string > | get_failure_impact (const std::string &name) const |
| Compute all nodes that would be impacted if the given node fails. | |
Private Member Functions | |
| bool | would_create_cycle_internal (const std::string &from, const std::string &to) const |
Private Attributes | |
| std::shared_mutex | mutex_ |
| std::unordered_map< std::string, std::shared_ptr< health_check > > | nodes_ |
| std::unordered_map< std::string, std::vector< std::string > > | dependencies_ |
| std::unordered_map< std::string, std::vector< std::string > > | dependents_ |
Directed acyclic graph for health check dependencies.
Models dependency relationships between health checks so that a check's dependencies are verified before the check itself. Prevents circular dependencies and supports topological ordering and impact analysis.
All public methods are thread-safe using std::shared_mutex (shared lock for reads, exclusive lock for writes).
Definition at line 337 of file health_monitor.h.
|
inline |
Add a dependency edge: dependent depends on dependency.
| dependent | Name of the node that depends on another |
| dependency | Name of the node being depended upon |
Definition at line 364 of file health_monitor.h.
References dependencies_, dependents_, kcenon::monitoring::invalid_state, mutex_, nodes_, kcenon::monitoring::not_found, and would_create_cycle_internal().
Referenced by kcenon::monitoring::health_monitor::add_dependency(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().


|
inline |
Add a health check node to the graph.
| name | Unique name for this node |
| check | The health check implementation |
Definition at line 345 of file health_monitor.h.
References kcenon::monitoring::already_exists, dependencies_, dependents_, mutex_, and nodes_.
Referenced by kcenon::monitoring::health_monitor::register_check(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().

|
inline |
Execute a health check after verifying all its dependencies are healthy.
| name | Node name to check |
Definition at line 473 of file health_monitor.h.
References kcenon::monitoring::health_check_result::degraded(), kcenon::monitoring::degraded, dependencies_, mutex_, nodes_, kcenon::monitoring::health_check_result::unhealthy(), and kcenon::monitoring::unhealthy.
Referenced by kcenon::monitoring::health_monitor::check(), and TEST_F().


|
inline |
Get the direct dependencies of a node.
| name | Node name to query |
Definition at line 388 of file health_monitor.h.
References dependencies_, and mutex_.
Referenced by TEST_F().

|
inline |
Get the nodes that directly depend on the given node.
| name | Node name to query |
Definition at line 403 of file health_monitor.h.
References dependents_, and mutex_.
Referenced by TEST_F().

|
inline |
Compute all nodes that would be impacted if the given node fails.
| name | Node name to analyze |
Definition at line 507 of file health_monitor.h.
References dependents_, and mutex_.
Referenced by TEST_F().

|
inline |
Compute a topological ordering of all nodes.
Definition at line 428 of file health_monitor.h.
References dependencies_, dependents_, mutex_, and nodes_.
Referenced by TEST_F().

|
inline |
Check whether adding an edge from -> to would create a cycle.
| from | Source node name |
| to | Target node name |
Definition at line 419 of file health_monitor.h.
References mutex_, and would_create_cycle_internal().
Referenced by TEST_F().


|
inlineprivate |
Definition at line 545 of file health_monitor.h.
References dependencies_.
Referenced by add_dependency(), and would_create_cycle().

|
private |
Definition at line 582 of file health_monitor.h.
Referenced by add_dependency(), add_node(), check_with_dependencies(), get_dependencies(), topological_sort(), and would_create_cycle_internal().
|
private |
Definition at line 583 of file health_monitor.h.
Referenced by add_dependency(), add_node(), get_dependents(), get_failure_impact(), and topological_sort().
|
mutableprivate |
Definition at line 580 of file health_monitor.h.
Referenced by add_dependency(), add_node(), check_with_dependencies(), get_dependencies(), get_dependents(), get_failure_impact(), topological_sort(), and would_create_cycle().
|
private |
Definition at line 581 of file health_monitor.h.
Referenced by add_dependency(), add_node(), check_with_dependencies(), and topological_sort().