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

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include "envoy/common/callback.h"
       4             : #include "envoy/common/pure.h"
       5             : 
       6             : #include "absl/strings/string_view.h"
       7             : #include "xds/core/v3/context_params.pb.h"
       8             : 
       9             : namespace Envoy {
      10             : namespace Config {
      11             : 
      12             : /**
      13             :  * A provider for xDS context parameters. These are currently derived from the bootstrap, but will
      14             :  * be set dynamically at runtime in the near future as we add support for dynamic context parameter
      15             :  * discovery and updates.
      16             :  *
      17             :  * In general, this is intended to be used only on the main thread, as part of the Server instance
      18             :  * interface and config subsystem.
      19             :  */
      20             : class ContextProvider {
      21             : public:
      22             :   /**
      23             :    * Callback type for when dynamic context changes. The argument provides the resource type URL for
      24             :    * the update.
      25             :    */
      26             :   using UpdateNotificationCb = std::function<void(absl::string_view)>;
      27             : 
      28        1324 :   virtual ~ContextProvider() = default;
      29             : 
      30             :   /**
      31             :    * @return const xds::core::v3::ContextParams& static node-level context parameters.
      32             :    */
      33             :   virtual const xds::core::v3::ContextParams& nodeContext() const PURE;
      34             : 
      35             :   /**
      36             :    * @param resource_type_url resource type URL for context parameters.
      37             :    * @return const xds::core::v3::ContextParams& dynamic node-level context parameters.
      38             :    */
      39             :   virtual const xds::core::v3::ContextParams&
      40             :   dynamicContext(absl::string_view resource_type_url) const PURE;
      41             : 
      42             :   /**
      43             :    * Set a dynamic context parameter.
      44             :    * @param resource_type_url resource type URL for context parameter.
      45             :    * @param key parameter key.
      46             :    * @param value parameter value.
      47             :    */
      48             :   virtual void setDynamicContextParam(absl::string_view resource_type_url, absl::string_view key,
      49             :                                       absl::string_view value) PURE;
      50             : 
      51             :   /**
      52             :    * Unset a dynamic context parameter.
      53             :    * @param resource_type_url resource type URL for context parameter.
      54             :    * @param key parameter key.
      55             :    */
      56             :   virtual void unsetDynamicContextParam(absl::string_view resource_type_url,
      57             :                                         absl::string_view key) PURE;
      58             : 
      59             :   /**
      60             :    * Register a callback for notification when the dynamic context changes.
      61             :    * @param callback notification callback.
      62             :    * @return Common::CallbackHandlePtr callback handle for removal.
      63             :    */
      64             :   ABSL_MUST_USE_RESULT virtual Common::CallbackHandlePtr
      65             :   addDynamicContextUpdateCallback(UpdateNotificationCb callback) const PURE;
      66             : };
      67             : 
      68             : } // namespace Config
      69             : } // namespace Envoy

Generated by: LCOV version 1.15