Coverage Report

Created: 2024-09-19 09:45

/proc/self/cwd/source/common/http/dependency_manager.h
Line
Count
Source
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
6.74k
  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
4.85k
      const envoy::extensions::filters::common::dependency::v3::FilterDependencies& dependencies) {
26
4.85k
    filter_chain_.push_back({filter_name, dependencies});
27
4.85k
  }
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