LCOV - code coverage report
Current view: top level - source/common/rds - rds_route_config_provider_impl.h (source / functions) Hit Total Coverage
Test: coverage.dat Lines: 3 4 75.0 %
Date: 2024-01-05 06:35:25 Functions: 3 4 75.0 %

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include <memory>
       4             : #include <string>
       5             : 
       6             : #include "envoy/rds/route_config_provider.h"
       7             : #include "envoy/rds/route_config_update_receiver.h"
       8             : #include "envoy/server/factory_context.h"
       9             : #include "envoy/thread_local/thread_local.h"
      10             : 
      11             : #include "source/common/rds/rds_route_config_subscription.h"
      12             : 
      13             : namespace Envoy {
      14             : namespace Rds {
      15             : 
      16             : /**
      17             :  * Implementation of RouteConfigProvider that fetches the route configuration dynamically using
      18             :  * the subscription.
      19             :  */
      20             : class RdsRouteConfigProviderImpl : public RouteConfigProvider,
      21             :                                    Logger::Loggable<Logger::Id::router> {
      22             : public:
      23             :   RdsRouteConfigProviderImpl(RdsRouteConfigSubscriptionSharedPtr&& subscription,
      24             :                              Server::Configuration::ServerFactoryContext& factory_context);
      25             : 
      26             :   ~RdsRouteConfigProviderImpl() override;
      27             : 
      28         100 :   RdsRouteConfigSubscription& subscription() { return *subscription_; }
      29             : 
      30             :   // RouteConfigProvider
      31           0 :   ConfigConstSharedPtr config() const override { return tls_->config_; }
      32             : 
      33             :   const absl::optional<ConfigInfo>& configInfo() const override;
      34          36 :   SystemTime lastUpdated() const override { return config_update_info_->lastUpdated(); }
      35             :   absl::Status onConfigUpdate() override;
      36             : 
      37             : private:
      38             :   struct ThreadLocalConfig : public ThreadLocal::ThreadLocalObject {
      39             :     ThreadLocalConfig(std::shared_ptr<const Config> initial_config)
      40         100 :         : config_(std::move(initial_config)) {}
      41             :     ConfigConstSharedPtr config_;
      42             :   };
      43             : 
      44             :   RdsRouteConfigSubscriptionSharedPtr subscription_;
      45             :   RouteConfigUpdatePtr& config_update_info_;
      46             :   ThreadLocal::TypedSlot<ThreadLocalConfig> tls_;
      47             : };
      48             : 
      49             : } // namespace Rds
      50             : } // namespace Envoy

Generated by: LCOV version 1.15