LCOV - code coverage report
Current view: top level - source/extensions/common/dynamic_forward_proxy - cluster_store.cc (source / functions) Hit Total Coverage
Test: coverage.dat Lines: 0 24 0.0 %
Date: 2024-01-05 06:35:25 Functions: 0 5 0.0 %

          Line data    Source code
       1             : #include "source/extensions/common/dynamic_forward_proxy/cluster_store.h"
       2             : 
       3             : namespace Envoy {
       4             : namespace Extensions {
       5             : namespace Common {
       6             : namespace DynamicForwardProxy {
       7             : 
       8             : SINGLETON_MANAGER_REGISTRATION(dynamic_forward_proxy_cluster_store);
       9             : 
      10           0 : DfpClusterSharedPtr DFPClusterStore::load(const std::string cluster_name) {
      11           0 :   ClusterStoreType& clusterStore = getClusterStore();
      12           0 :   absl::ReaderMutexLock lock(&clusterStore.mutex_);
      13           0 :   auto it = clusterStore.map_.find(cluster_name);
      14           0 :   if (it != clusterStore.map_.end()) {
      15           0 :     return it->second.lock();
      16           0 :   }
      17           0 :   return nullptr;
      18           0 : }
      19             : 
      20           0 : void DFPClusterStore::save(const std::string cluster_name, DfpClusterSharedPtr cluster) {
      21           0 :   ClusterStoreType& clusterStore = getClusterStore();
      22           0 :   absl::WriterMutexLock lock(&clusterStore.mutex_);
      23           0 :   clusterStore.map_[cluster_name] = std::move(cluster);
      24           0 : }
      25             : 
      26           0 : void DFPClusterStore::remove(const std::string cluster_name) {
      27           0 :   ClusterStoreType& clusterStore = getClusterStore();
      28           0 :   absl::WriterMutexLock lock(&clusterStore.mutex_);
      29           0 :   clusterStore.map_.erase(cluster_name);
      30           0 : }
      31             : 
      32           0 : DFPClusterStoreSharedPtr DFPClusterStoreFactory::get() {
      33           0 :   return singleton_manager_.getTyped<DFPClusterStore>(
      34           0 :       SINGLETON_MANAGER_REGISTERED_NAME(dynamic_forward_proxy_cluster_store),
      35           0 :       []() { return std::make_shared<DFPClusterStore>(); });
      36           0 : }
      37             : 
      38             : } // namespace DynamicForwardProxy
      39             : } // namespace Common
      40             : } // namespace Extensions
      41             : } // namespace Envoy

Generated by: LCOV version 1.15