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

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include "envoy/extensions/filters/common/dependency/v3/dependency.pb.h"
       4             : 
       5             : #include "absl/status/status.h"
       6             : 
       7             : namespace Envoy {
       8             : namespace Http {
       9             : 
      10             : /**
      11             :  * Validation for an http filter chain based on the factory-level
      12             :  * FilterDependencies specification. @see NamedHttpFilterConfigFactory
      13             :  * Currently only validates decode dependencies.
      14             :  */
      15             : class DependencyManager {
      16             : public:
      17         299 :   DependencyManager() = default;
      18             : 
      19             :   /**
      20             :    * Register each filter in an http filter chain, using name and dependencies
      21             :    * from the filter factory. Filters must be registered in decode path order.
      22             :    */
      23             :   void registerFilter(
      24             :       const std::string& filter_name,
      25         300 :       const envoy::extensions::filters::common::dependency::v3::FilterDependencies& dependencies) {
      26         300 :     filter_chain_.push_back({filter_name, dependencies});
      27         300 :   }
      28             : 
      29             :   /**
      30             :    * Returns StatusCode::kOk if the decode path of the filter chain is valid.
      31             :    * A filter chain is valid iff for each filter, every decode dependency has
      32             :    * been provided by a previous filter.
      33             :    * Returns StatusCode::kNotFoundError if the decode path is invalid, with
      34             :    * details of the first dependency violation found.
      35             :    *
      36             :    * TODO(auni53): Change this to a general valid() that checks decode and
      37             :    * encode path.
      38             :    */
      39             :   absl::Status validDecodeDependencies();
      40             : 
      41             : private:
      42             :   // Mapping of filter names to dependencies, in decode path order.
      43             :   std::vector<std::pair<std::string,
      44             :                         envoy::extensions::filters::common::dependency::v3::FilterDependencies>>
      45             :       filter_chain_;
      46             : };
      47             : 
      48             : } // namespace Http
      49             : } // namespace Envoy

Generated by: LCOV version 1.15