|
Monitoring System 0.1.0
System resource monitoring with pluggable collectors and alerting
|
Error boundary implementation for resilient operations. More...
#include <error_boundary.h>

Public Types | |
| using | config = error_boundary_config |
Public Member Functions | |
| error_boundary () | |
| error_boundary (const std::string &name) | |
| error_boundary (const std::string &name, const config &cfg) | |
| template<typename Func > | |
| auto | execute (Func &&func) -> common::Result< T > |
| Execute a function within the error boundary. | |
| template<typename Func , typename FallbackFunc > | |
| auto | execute (Func &&func, FallbackFunc &&fallback) -> common::Result< T > |
| Execute with custom fallback function. | |
| void | set_error_handler (std::function< void(const error_info &, degradation_level)> handler) |
| Set error handler callback. | |
| void | set_fallback_strategy (std::shared_ptr< fallback_strategy_interface< T > > strategy) |
| Set fallback strategy. | |
| degradation_level | get_degradation_level () const |
| Get current degradation level. | |
| void | force_degradation (degradation_level level) |
| Force degradation to a specific level. | |
| common::Result< bool > | is_healthy () const |
| Check if the boundary is healthy. | |
| error_boundary_metrics | get_metrics () const |
| Get metrics. | |
| const std::string & | get_name () const |
| Get boundary name. | |
Private Member Functions | |
| common::Result< T > | handle_failure (const common::error_info &err) |
| void | handle_success () |
| void | upgrade_degradation () |
| void | downgrade_degradation () |
Private Attributes | |
| std::string | name_ |
| config | config_ |
| std::function< void(const error_info &, degradation_level)> | error_handler_ |
| std::shared_ptr< fallback_strategy_interface< T > > | fallback_strategy_ |
| error_boundary_metrics | metrics_ |
| degradation_level | current_degradation_level_ = degradation_level::normal |
| size_t | consecutive_failures_ = 0 |
Error boundary implementation for resilient operations.
Definition at line 198 of file error_boundary.h.
| using kcenon::monitoring::error_boundary< T >::config = error_boundary_config |
Definition at line 200 of file error_boundary.h.
|
inline |
Definition at line 202 of file error_boundary.h.
|
inlineexplicit |
Definition at line 204 of file error_boundary.h.
References kcenon::monitoring::error_boundary< T >::config_, and kcenon::monitoring::error_boundary_config::name.
|
inlineexplicit |
Definition at line 208 of file error_boundary.h.
References kcenon::monitoring::error_boundary< T >::config_, and kcenon::monitoring::error_boundary_config::name.
|
inlineprivate |
Definition at line 378 of file error_boundary.h.
References kcenon::monitoring::error_boundary< T >::current_degradation_level_.
Referenced by kcenon::monitoring::error_boundary< T >::handle_success().

|
inline |
Execute a function within the error boundary.
Definition at line 217 of file error_boundary.h.
References kcenon::monitoring::error_boundary_metrics::failed_operations, kcenon::monitoring::error_boundary< T >::handle_failure(), kcenon::monitoring::error_boundary< T >::handle_success(), kcenon::monitoring::error_boundary< T >::metrics_, kcenon::monitoring::operation_failed, kcenon::monitoring::error_boundary_metrics::successful_operations, kcenon::monitoring::error_info::to_common_error(), and kcenon::monitoring::error_boundary_metrics::total_operations.
Referenced by demonstrate_error_boundaries(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().


|
inline |
Execute with custom fallback function.
Definition at line 247 of file error_boundary.h.
References kcenon::monitoring::error_boundary< T >::current_degradation_level_, kcenon::monitoring::error_boundary_metrics::failed_operations, kcenon::monitoring::fallback, kcenon::monitoring::error_info::from_common_error(), kcenon::monitoring::error_boundary< T >::handle_success(), kcenon::monitoring::error_boundary< T >::metrics_, kcenon::monitoring::operation_failed, kcenon::monitoring::error_boundary_metrics::successful_operations, and kcenon::monitoring::error_boundary_metrics::total_operations.

|
inline |
Force degradation to a specific level.
Definition at line 294 of file error_boundary.h.
References kcenon::monitoring::error_boundary< T >::config_, kcenon::monitoring::error_boundary< T >::current_degradation_level_, and kcenon::monitoring::error_boundary_config::max_degradation.
Referenced by TEST_F().

|
inline |
Get current degradation level.
Definition at line 287 of file error_boundary.h.
References kcenon::monitoring::error_boundary< T >::current_degradation_level_.
Referenced by TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().

|
inline |
Get metrics.
Definition at line 311 of file error_boundary.h.
References kcenon::monitoring::error_boundary< T >::metrics_.
Referenced by demonstrate_error_boundaries(), TEST_F(), and TEST_F().

|
inline |
Get boundary name.
Definition at line 318 of file error_boundary.h.
References kcenon::monitoring::error_boundary< T >::name_.
|
inlineprivate |
Definition at line 323 of file error_boundary.h.
References kcenon::monitoring::error_boundary< T >::config_, kcenon::monitoring::error_boundary< T >::consecutive_failures_, kcenon::monitoring::error_boundary< T >::current_degradation_level_, kcenon::monitoring::degrade, kcenon::monitoring::error_boundary< T >::error_handler_, kcenon::monitoring::error_boundary_config::error_threshold, kcenon::monitoring::fail_fast, kcenon::monitoring::fallback, kcenon::monitoring::error_boundary< T >::fallback_strategy_, kcenon::monitoring::error_info::from_common_error(), kcenon::monitoring::isolate, kcenon::monitoring::error_boundary_config::policy, kcenon::monitoring::service_degraded, and kcenon::monitoring::error_boundary< T >::upgrade_degradation().
Referenced by kcenon::monitoring::error_boundary< T >::execute().


|
inlineprivate |
Definition at line 359 of file error_boundary.h.
References kcenon::monitoring::error_boundary< T >::config_, kcenon::monitoring::error_boundary< T >::consecutive_failures_, kcenon::monitoring::error_boundary< T >::current_degradation_level_, kcenon::monitoring::error_boundary< T >::downgrade_degradation(), kcenon::monitoring::error_boundary_config::enable_automatic_recovery, kcenon::monitoring::error_boundary< T >::metrics_, kcenon::monitoring::normal, and kcenon::monitoring::error_boundary_metrics::recovery_attempts.
Referenced by kcenon::monitoring::error_boundary< T >::execute(), and kcenon::monitoring::error_boundary< T >::execute().


|
inline |
Check if the boundary is healthy.
Definition at line 303 of file error_boundary.h.
References kcenon::monitoring::error_boundary< T >::current_degradation_level_, kcenon::monitoring::healthy, and kcenon::monitoring::normal.
Referenced by TEST_F().

|
inline |
Set error handler callback.
Definition at line 273 of file error_boundary.h.
References kcenon::monitoring::error_boundary< T >::error_handler_.
Referenced by demonstrate_error_boundaries().

|
inline |
Set fallback strategy.
Definition at line 280 of file error_boundary.h.
References kcenon::monitoring::error_boundary< T >::fallback_strategy_.
Referenced by TEST_F(), TEST_F(), and TEST_F().

|
inlineprivate |
Definition at line 370 of file error_boundary.h.
References kcenon::monitoring::error_boundary< T >::config_, kcenon::monitoring::error_boundary< T >::current_degradation_level_, and kcenon::monitoring::error_boundary_config::max_degradation.
Referenced by kcenon::monitoring::error_boundary< T >::handle_failure().

|
private |
Definition at line 386 of file error_boundary.h.
Referenced by kcenon::monitoring::error_boundary< T >::error_boundary(), kcenon::monitoring::error_boundary< T >::error_boundary(), kcenon::monitoring::error_boundary< T >::force_degradation(), kcenon::monitoring::error_boundary< T >::handle_failure(), kcenon::monitoring::error_boundary< T >::handle_success(), and kcenon::monitoring::error_boundary< T >::upgrade_degradation().
|
private |
Definition at line 391 of file error_boundary.h.
Referenced by kcenon::monitoring::error_boundary< T >::handle_failure(), and kcenon::monitoring::error_boundary< T >::handle_success().
|
private |
Definition at line 390 of file error_boundary.h.
Referenced by kcenon::monitoring::error_boundary< T >::downgrade_degradation(), kcenon::monitoring::error_boundary< T >::execute(), kcenon::monitoring::error_boundary< T >::force_degradation(), kcenon::monitoring::error_boundary< T >::get_degradation_level(), kcenon::monitoring::error_boundary< T >::handle_failure(), kcenon::monitoring::error_boundary< T >::handle_success(), kcenon::monitoring::error_boundary< T >::is_healthy(), and kcenon::monitoring::error_boundary< T >::upgrade_degradation().
|
private |
Definition at line 387 of file error_boundary.h.
Referenced by kcenon::monitoring::error_boundary< T >::handle_failure(), and kcenon::monitoring::error_boundary< T >::set_error_handler().
|
private |
Definition at line 388 of file error_boundary.h.
Referenced by kcenon::monitoring::error_boundary< T >::handle_failure(), and kcenon::monitoring::error_boundary< T >::set_fallback_strategy().
|
mutableprivate |
|
private |
Definition at line 385 of file error_boundary.h.
Referenced by kcenon::monitoring::error_boundary< T >::get_name().