48 static constexpr auto values = std::array{
55 static constexpr std::string_view module_name =
"health_check";
119 [[nodiscard]]
virtual std::string
get_name()
const = 0;
137 [[nodiscard]]
virtual std::chrono::milliseconds
get_timeout()
const {
138 return std::chrono::milliseconds{5000};
189 std::chrono::milliseconds timeout = std::chrono::milliseconds{5000})
190 :
name_(std::move(name))
204 result.
message =
"No check function configured";
Result type for error handling with member function support.
Abstract base class for health checks.
health_check & operator=(const health_check &)=delete
virtual bool is_critical() const
Check if this health check is critical.
virtual std::chrono::milliseconds get_timeout() const
Get timeout duration for this health check.
virtual health_check_type get_type() const =0
Get the type of this health check.
health_check & operator=(health_check &&)=delete
virtual ~health_check()=default
virtual health_check_result check()=0
Perform the health check.
health_check(health_check &&)=delete
health_check(const health_check &)=delete
virtual std::string get_name() const =0
Get the unique name of this health check.
Health check implementation using a lambda function.
std::chrono::milliseconds timeout_
std::string get_name() const override
Get the unique name of this health check.
health_check_result check() override
Perform the health check.
std::function< health_check_result()> check_function
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.
bool is_critical() const override
Check if this health check is critical.
std::chrono::milliseconds get_timeout() const override
Get timeout duration for this health check.
health_check_type get_type() const override
Get the type of this health check.
Generic enum serialization utilities using C++20 concepts.
Standard monitoring interface for all systems.
Result< health_check_type > health_check_type_from_string(const std::string &str)
Convert string to health check type.
health_check_type
Types of health checks supported by the system.
std::string to_string(log_level level)
Convert log level to string.
Result< Enum > enum_from_string(std::string_view str)
Convert a string to its enum value (case-insensitive)
std::string enum_to_string(Enum value)
Convert an enum value to its string representation.
Primary template for enum traits (must be specialized for each enum)
Result of a health check operation.