Monitoring System 0.1.0
System resource monitoring with pluggable collectors and alerting
Loading...
Searching...
No Matches
kcenon::monitoring::error_boundary_registry Class Reference

Error boundary registry for managing multiple boundaries. More...

#include <graceful_degradation.h>

Collaboration diagram for kcenon::monitoring::error_boundary_registry:
Collaboration graph

Public Member Functions

template<typename T >
void register_boundary (const std::string &name, std::shared_ptr< error_boundary< T > > boundary)
 
template<typename T >
std::shared_ptr< error_boundary< T > > get_boundary (const std::string &name)
 
void remove_boundary (const std::string &name)
 
std::vector< std::string > get_all_names () const
 
void clear ()
 

Private Attributes

std::mutex mutex_
 
std::unordered_map< std::string, std::any > registry_
 

Detailed Description

Error boundary registry for managing multiple boundaries.

Definition at line 395 of file graceful_degradation.h.

Member Function Documentation

◆ clear()

void kcenon::monitoring::error_boundary_registry::clear ( )
inline

Definition at line 432 of file graceful_degradation.h.

432 {
433 std::lock_guard<std::mutex> lock(mutex_);
434 registry_.clear();
435 }
std::unordered_map< std::string, std::any > registry_

References mutex_, and registry_.

Referenced by ErrorBoundariesTest::TearDown().

Here is the caller graph for this function:

◆ get_all_names()

std::vector< std::string > kcenon::monitoring::error_boundary_registry::get_all_names ( ) const
inline

Definition at line 422 of file graceful_degradation.h.

422 {
423 std::lock_guard<std::mutex> lock(mutex_);
424 std::vector<std::string> names;
425 names.reserve(registry_.size());
426 for (const auto& [name, boundary] : registry_) {
427 names.push_back(name);
428 }
429 return names;
430 }

References mutex_, and registry_.

◆ get_boundary()

template<typename T >
std::shared_ptr< error_boundary< T > > kcenon::monitoring::error_boundary_registry::get_boundary ( const std::string & name)
inline

Definition at line 404 of file graceful_degradation.h.

404 {
405 std::lock_guard<std::mutex> lock(mutex_);
406 auto it = registry_.find(name);
407 if (it != registry_.end()) {
408 try {
409 return std::any_cast<std::shared_ptr<error_boundary<T>>>(it->second);
410 } catch (const std::bad_any_cast&) {
411 return nullptr;
412 }
413 }
414 return nullptr;
415 }

References mutex_, and registry_.

◆ register_boundary()

template<typename T >
void kcenon::monitoring::error_boundary_registry::register_boundary ( const std::string & name,
std::shared_ptr< error_boundary< T > > boundary )
inline

Definition at line 398 of file graceful_degradation.h.

398 {
399 std::lock_guard<std::mutex> lock(mutex_);
400 registry_[name] = std::move(boundary);
401 }

References mutex_, and registry_.

◆ remove_boundary()

void kcenon::monitoring::error_boundary_registry::remove_boundary ( const std::string & name)
inline

Definition at line 417 of file graceful_degradation.h.

417 {
418 std::lock_guard<std::mutex> lock(mutex_);
419 registry_.erase(name);
420 }

References mutex_, and registry_.

Member Data Documentation

◆ mutex_

std::mutex kcenon::monitoring::error_boundary_registry::mutex_
mutableprivate

◆ registry_

std::unordered_map<std::string, std::any> kcenon::monitoring::error_boundary_registry::registry_
private

The documentation for this class was generated from the following file: