|
Common System 0.2.0
Common interfaces and patterns for system integration
|
Fluent builder for creating health checks. More...
#include <health_check_builder.h>

Public Types | |
| using | check_fn_type = std::function<health_check_result()> |
Public Member Functions | |
| health_check_builder ()=default | |
| health_check_builder & | name (std::string value) |
| Set the health check name. | |
| health_check_builder & | type (health_check_type value) |
| Set the health check type. | |
| health_check_builder & | with_check (check_fn_type fn) |
| Set the check function. | |
| health_check_builder & | critical (bool value) |
| Set whether this check is critical. | |
| health_check_builder & | timeout (std::chrono::milliseconds value) |
| Set the check timeout. | |
| Result< std::shared_ptr< health_check > > | build () const |
| Build the health check. | |
| std::shared_ptr< health_check > | build_unsafe () const |
| Build the health check without validation. | |
| health_check_builder & | reset () |
| Reset the builder to initial state. | |
Private Attributes | |
| std::string | name_ |
| health_check_type | type_ = health_check_type::custom |
| check_fn_type | check_fn_ |
| bool | critical_ = true |
| std::chrono::milliseconds | timeout_ {5000} |
Fluent builder for creating health checks.
This class provides a builder pattern for constructing health checks with a fluent API. It allows setting various properties before creating the final health check object.
Example usage:
Definition at line 48 of file health_check_builder.h.
| using kcenon::common::interfaces::health_check_builder::check_fn_type = std::function<health_check_result()> |
Definition at line 50 of file health_check_builder.h.
|
default |
|
inlinenodiscard |
Build the health check.
Validates that all required fields are set before building.
Definition at line 110 of file health_check_builder.h.
References check_fn_, critical_, name_, kcenon::common::ok(), timeout_, and type_.

|
inlinenodiscard |
Build the health check without validation.
Use this method only when you're sure all required fields are set. For safer construction, use build() instead.
Definition at line 131 of file health_check_builder.h.
References check_fn_, critical_, name_, timeout_, and type_.
|
inline |
Set whether this check is critical.
| value | true if critical |
Definition at line 89 of file health_check_builder.h.
References critical_.
|
inline |
Set the health check name.
| value | Health check name |
Definition at line 59 of file health_check_builder.h.
References name_.
|
inline |
Reset the builder to initial state.
Definition at line 140 of file health_check_builder.h.
References check_fn_, critical_, kcenon::common::interfaces::custom, name_, timeout_, and type_.
|
inline |
Set the check timeout.
| value | Timeout duration |
Definition at line 99 of file health_check_builder.h.
References timeout_.
|
inline |
Set the health check type.
| value | Health check type |
Definition at line 69 of file health_check_builder.h.
References type_.
|
inline |
Set the check function.
| fn | Function to execute for health check |
Definition at line 79 of file health_check_builder.h.
References check_fn_.
|
private |
Definition at line 152 of file health_check_builder.h.
Referenced by build(), build_unsafe(), reset(), and with_check().
|
private |
Definition at line 153 of file health_check_builder.h.
Referenced by build(), build_unsafe(), critical(), and reset().
|
private |
Definition at line 150 of file health_check_builder.h.
Referenced by build(), build_unsafe(), name(), and reset().
|
private |
Definition at line 154 of file health_check_builder.h.
Referenced by build(), build_unsafe(), reset(), and timeout().
|
private |
Definition at line 151 of file health_check_builder.h.
Referenced by build(), build_unsafe(), reset(), and type().