LCOV - code coverage report
Current view: top level - envoy/config - xds_config_tracker.h (source / functions) Hit Total Coverage
Test: coverage.dat Lines: 0 1 0.0 %
Date: 2024-01-05 06:35:25 Functions: 0 1 0.0 %

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include <string>
       4             : #include <vector>
       5             : 
       6             : #include "envoy/api/api.h"
       7             : #include "envoy/common/optref.h"
       8             : #include "envoy/config/subscription.h"
       9             : #include "envoy/config/typed_config.h"
      10             : #include "envoy/protobuf/message_validator.h"
      11             : #include "envoy/stats/scope.h"
      12             : 
      13             : #include "source/common/protobuf/protobuf.h"
      14             : 
      15             : #include "google/rpc/status.pb.h"
      16             : 
      17             : namespace Envoy {
      18             : namespace Config {
      19             : 
      20             : /**
      21             :  * An interface for hooking into xDS update events to provide the ablility to use some external
      22             :  * processor in xDS update. This tracker provides the process point when the discovery response
      23             :  * is received, when the resources are successfully processed and applied, and when there is any
      24             :  * failure.
      25             :  *
      26             :  * Instance of this interface get invoked on the main Envoy thread. Thus, it is important
      27             :  * for implementations of this interface to not execute any blocking operations on the same
      28             :  * thread.
      29             :  */
      30             : class XdsConfigTracker {
      31             : public:
      32             :   virtual ~XdsConfigTracker() = default;
      33             : 
      34             :   /**
      35             :    * Invoked when SotW xDS configuration updates have been successfully parsed, applied on
      36             :    * the Envoy instance, and are about to be ACK'ed.
      37             :    *
      38             :    * For SotW, the passed resources contain all the received resources except for the heart-beat
      39             :    * ones in the original message. The call of this method means there is a subscriber for this
      40             :    * type_url and the type of resource is same as the message's type_url.
      41             :    *
      42             :    * Note: this method is called when *all* the resources in a response are accepted.
      43             :    *
      44             :    * @param type_url The type url of xDS message.
      45             :    * @param resources A list of decoded resources to add to the current state.
      46             :    */
      47             :   virtual void onConfigAccepted(const absl::string_view type_url,
      48             :                                 const std::vector<DecodedResourcePtr>& resources) PURE;
      49             : 
      50             :   /**
      51             :    * Invoked when Delta xDS configuration updates have been successfully accepted, applied on
      52             :    * the Envoy instance, and are about to be ACK'ed.
      53             :    *
      54             :    * For Delta, added_resources contains all the received added resources except for the heart-beat
      55             :    * ones in the original message, and the removed resources are the same in the xDS message.
      56             :    *
      57             :    * Note: this method is called when *all* the resources in a response are accepted.
      58             :    *
      59             :    * @param type_url The type url of xDS message.
      60             :    * @param added_resources A list of decoded resources to add to the current state.
      61             :    * @param removed_resources A list of resources to remove from the current state.
      62             :    */
      63             :   virtual void onConfigAccepted(
      64             :       const absl::string_view type_url,
      65             :       const Protobuf::RepeatedPtrField<envoy::service::discovery::v3::Resource>& added_resources,
      66             :       const Protobuf::RepeatedPtrField<std::string>& removed_resources) PURE;
      67             : 
      68             :   /**
      69             :    * Invoked when xds configs are rejected during xDS ingestion.
      70             :    *
      71             :    * @param message The SotW discovery response message body.
      72             :    * @param details The process state and error details.
      73             :    */
      74             :   virtual void onConfigRejected(const envoy::service::discovery::v3::DiscoveryResponse& message,
      75             :                                 const absl::string_view error_detail) PURE;
      76             : 
      77             :   /**
      78             :    * Invoked when xds configs are rejected during xDS ingestion.
      79             :    *
      80             :    * @param message The Delta discovery response message body.
      81             :    * @param details The process state and error details.
      82             :    */
      83             :   virtual void
      84             :   onConfigRejected(const envoy::service::discovery::v3::DeltaDiscoveryResponse& message,
      85             :                    const absl::string_view error_detail) PURE;
      86             : };
      87             : 
      88             : using XdsConfigTrackerPtr = std::unique_ptr<XdsConfigTracker>;
      89             : using XdsConfigTrackerOptRef = OptRef<XdsConfigTracker>;
      90             : 
      91             : /**
      92             :  * A factory abstract class for creating instances of XdsConfigTracker.
      93             :  */
      94             : class XdsConfigTrackerFactory : public Config::TypedFactory {
      95             : public:
      96             :   ~XdsConfigTrackerFactory() override = default;
      97             : 
      98             :   /**
      99             :    * Creates an XdsConfigTracker using the given config.
     100             :    */
     101             :   virtual XdsConfigTrackerPtr
     102             :   createXdsConfigTracker(const ProtobufWkt::Any& config,
     103             :                          ProtobufMessage::ValidationVisitor& validation_visitor, Api::Api& api,
     104             :                          Event::Dispatcher& dispatcher) PURE;
     105             : 
     106           0 :   std::string category() const override { return "envoy.config.xds_tracker"; }
     107             : };
     108             : 
     109             : } // namespace Config
     110             : } // namespace Envoy

Generated by: LCOV version 1.15