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

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include <functional>
       4             : #include <string>
       5             : #include <vector>
       6             : 
       7             : #include "envoy/config/cluster/v3/cluster.pb.h"
       8             : #include "envoy/config/cluster/v3/cluster.pb.validate.h"
       9             : #include "envoy/config/core/v3/config_source.pb.h"
      10             : #include "envoy/config/subscription.h"
      11             : #include "envoy/protobuf/message_validator.h"
      12             : #include "envoy/stats/scope.h"
      13             : #include "envoy/upstream/cluster_manager.h"
      14             : 
      15             : #include "source/common/config/subscription_base.h"
      16             : #include "source/common/protobuf/protobuf.h"
      17             : #include "source/common/upstream/cds_api_helper.h"
      18             : 
      19             : namespace Envoy {
      20             : namespace Upstream {
      21             : 
      22             : /**
      23             :  * CDS API implementation that fetches via Subscription.
      24             :  */
      25             : class CdsApiImpl : public CdsApi,
      26             :                    Envoy::Config::SubscriptionBase<envoy::config::cluster::v3::Cluster> {
      27             : public:
      28             :   static CdsApiPtr create(const envoy::config::core::v3::ConfigSource& cds_config,
      29             :                           const xds::core::v3::ResourceLocator* cds_resources_locator,
      30             :                           ClusterManager& cm, Stats::Scope& scope,
      31             :                           ProtobufMessage::ValidationVisitor& validation_visitor);
      32             : 
      33             :   // Upstream::CdsApi
      34          28 :   void initialize() override { subscription_->start({}); }
      35          28 :   void setInitializedCb(std::function<void()> callback) override {
      36          28 :     initialize_callback_ = callback;
      37          28 :   }
      38          28 :   const std::string versionInfo() const override { return helper_.versionInfo(); }
      39             : 
      40             : private:
      41             :   // Config::SubscriptionCallbacks
      42             :   absl::Status onConfigUpdate(const std::vector<Config::DecodedResourceRef>& resources,
      43             :                               const std::string& version_info) override;
      44             :   absl::Status onConfigUpdate(const std::vector<Config::DecodedResourceRef>& added_resources,
      45             :                               const Protobuf::RepeatedPtrField<std::string>& removed_resources,
      46             :                               const std::string& system_version_info) override;
      47             :   void onConfigUpdateFailed(Envoy::Config::ConfigUpdateFailureReason reason,
      48             :                             const EnvoyException* e) override;
      49             :   CdsApiImpl(const envoy::config::core::v3::ConfigSource& cds_config,
      50             :              const xds::core::v3::ResourceLocator* cds_resources_locator, ClusterManager& cm,
      51             :              Stats::Scope& scope, ProtobufMessage::ValidationVisitor& validation_visitor);
      52             :   void runInitializeCallbackIfAny();
      53             : 
      54             :   CdsApiHelper helper_;
      55             :   ClusterManager& cm_;
      56             :   Stats::ScopeSharedPtr scope_;
      57             :   Config::SubscriptionPtr subscription_;
      58             :   std::function<void()> initialize_callback_;
      59             : };
      60             : 
      61             : } // namespace Upstream
      62             : } // namespace Envoy

Generated by: LCOV version 1.15