/proc/self/cwd/source/common/router/vhds.h
Line | Count | Source (jump to first uncovered line) |
1 | | #pragma once |
2 | | |
3 | | #include <cstdint> |
4 | | #include <functional> |
5 | | #include <string> |
6 | | |
7 | | #include "envoy/config/core/v3/config_source.pb.h" |
8 | | #include "envoy/config/route/v3/route_components.pb.h" |
9 | | #include "envoy/config/route/v3/route_components.pb.validate.h" |
10 | | #include "envoy/config/subscription.h" |
11 | | #include "envoy/http/codes.h" |
12 | | #include "envoy/local_info/local_info.h" |
13 | | #include "envoy/router/rds.h" |
14 | | #include "envoy/router/route_config_update_receiver.h" |
15 | | #include "envoy/server/filter_config.h" |
16 | | #include "envoy/service/discovery/v3/discovery.pb.h" |
17 | | #include "envoy/singleton/instance.h" |
18 | | #include "envoy/stats/scope.h" |
19 | | #include "envoy/thread_local/thread_local.h" |
20 | | |
21 | | #include "source/common/common/logger.h" |
22 | | #include "source/common/config/subscription_base.h" |
23 | | #include "source/common/init/target_impl.h" |
24 | | #include "source/common/protobuf/utility.h" |
25 | | |
26 | | #include "absl/container/node_hash_set.h" |
27 | | |
28 | | namespace Envoy { |
29 | | namespace Router { |
30 | | |
31 | | #define ALL_VHDS_STATS(COUNTER) \ |
32 | | COUNTER(config_reload) \ |
33 | | COUNTER(update_empty) |
34 | | |
35 | | struct VhdsStats { |
36 | | ALL_VHDS_STATS(GENERATE_COUNTER_STRUCT) |
37 | | }; |
38 | | |
39 | | class VhdsSubscription : Envoy::Config::SubscriptionBase<envoy::config::route::v3::VirtualHost>, |
40 | | Logger::Loggable<Logger::Id::router> { |
41 | | public: |
42 | | VhdsSubscription(RouteConfigUpdatePtr& config_update_info, |
43 | | Server::Configuration::ServerFactoryContext& factory_context, |
44 | | const std::string& stat_prefix, Rds::RouteConfigProvider* route_config_provider); |
45 | | |
46 | 0 | ~VhdsSubscription() override { init_target_.ready(); } |
47 | | |
48 | 0 | void registerInitTargetWithInitManager(Init::Manager& m) { m.add(init_target_); } |
49 | | void updateOnDemand(const std::string& with_route_config_name_prefix); |
50 | | static std::string domainNameToAlias(const std::string& route_config_name, |
51 | 0 | const std::string& domain) { |
52 | 0 | return route_config_name + "/" + domain; |
53 | 0 | } |
54 | 0 | static std::string aliasToDomainName(const std::string& alias) { |
55 | 0 | const auto pos = alias.find_last_of('/'); |
56 | 0 | return pos == std::string::npos ? alias : alias.substr(pos + 1); |
57 | 0 | } |
58 | | |
59 | | private: |
60 | | // Config::SubscriptionCallbacks |
61 | | absl::Status onConfigUpdate(const std::vector<Envoy::Config::DecodedResourceRef>&, |
62 | 0 | const std::string&) override { |
63 | 0 | return absl::OkStatus(); |
64 | 0 | } |
65 | | absl::Status onConfigUpdate(const std::vector<Envoy::Config::DecodedResourceRef>&, |
66 | | const Protobuf::RepeatedPtrField<std::string>&, |
67 | | const std::string&) override; |
68 | | void onConfigUpdateFailed(Envoy::Config::ConfigUpdateFailureReason reason, |
69 | | const EnvoyException* e) override; |
70 | | |
71 | | RouteConfigUpdatePtr& config_update_info_; |
72 | | Stats::ScopeSharedPtr scope_; |
73 | | VhdsStats stats_; |
74 | | Envoy::Config::SubscriptionPtr subscription_; |
75 | | Init::TargetImpl init_target_; |
76 | | Rds::RouteConfigProvider* route_config_provider_; |
77 | | }; |
78 | | |
79 | | using VhdsSubscriptionPtr = std::unique_ptr<VhdsSubscription>; |
80 | | |
81 | | } // namespace Router |
82 | | } // namespace Envoy |