/proc/self/cwd/source/extensions/filters/network/thrift_proxy/router/config.h
Line | Count | Source (jump to first uncovered line) |
1 | | #pragma once |
2 | | |
3 | | #include "envoy/extensions/filters/network/thrift_proxy/router/v3/router.pb.h" |
4 | | #include "envoy/extensions/filters/network/thrift_proxy/router/v3/router.pb.validate.h" |
5 | | |
6 | | #include "source/extensions/filters/network/thrift_proxy/filters/factory_base.h" |
7 | | #include "source/extensions/filters/network/thrift_proxy/router/router_impl.h" |
8 | | |
9 | | namespace Envoy { |
10 | | namespace Extensions { |
11 | | namespace NetworkFilters { |
12 | | namespace ThriftProxy { |
13 | | namespace Router { |
14 | | |
15 | | class RouterFilterConfig |
16 | | : public ThriftFilters::FactoryBase< |
17 | | envoy::extensions::filters::network::thrift_proxy::router::v3::Router> { |
18 | | public: |
19 | 4 | RouterFilterConfig() : FactoryBase("envoy.filters.thrift.router") {} |
20 | | |
21 | | private: |
22 | | ThriftFilters::FilterFactoryCb createFilterFactoryFromProtoTyped( |
23 | | const envoy::extensions::filters::network::thrift_proxy::router::v3::Router& proto_config, |
24 | | const std::string& stat_prefix, Server::Configuration::FactoryContext& context) override; |
25 | | }; |
26 | | |
27 | | class ConfigImpl : public Config, Logger::Loggable<Logger::Id::config> { |
28 | | public: |
29 | | ConfigImpl( |
30 | | const envoy::extensions::filters::network::thrift_proxy::v3::RouteConfiguration& config, |
31 | 0 | Server::Configuration::ServerFactoryContext& context, bool validate_clusters_default) { |
32 | 0 | absl::optional<Upstream::ClusterManager::ClusterInfoMaps> validation_clusters; |
33 | 0 | if (PROTOBUF_GET_WRAPPED_OR_DEFAULT(config, validate_clusters, validate_clusters_default)) { |
34 | 0 | validation_clusters = context.clusterManager().clusters(); |
35 | 0 | } |
36 | 0 | route_matcher_ = std::make_unique<RouteMatcher>(config, validation_clusters); |
37 | 0 | } |
38 | | |
39 | | // Config |
40 | 0 | RouteConstSharedPtr route(const MessageMetadata& metadata, uint64_t random_value) const override { |
41 | 0 | return route_matcher_->route(metadata, random_value); |
42 | 0 | } |
43 | | |
44 | | private: |
45 | | std::unique_ptr<RouteMatcher> route_matcher_; |
46 | | }; |
47 | | |
48 | | class NullConfigImpl : public Config { |
49 | | public: |
50 | 0 | RouteConstSharedPtr route(const MessageMetadata&, uint64_t) const override { return nullptr; } |
51 | | }; |
52 | | |
53 | | } // namespace Router |
54 | | } // namespace ThriftProxy |
55 | | } // namespace NetworkFilters |
56 | | } // namespace Extensions |
57 | | } // namespace Envoy |