Line data Source code
1 : #pragma once 2 : 3 : #include <string> 4 : 5 : #include "envoy/rds/config_traits.h" 6 : #include "envoy/rds/route_config_update_receiver.h" 7 : #include "envoy/server/factory_context.h" 8 : 9 : namespace Envoy { 10 : namespace Rds { 11 : 12 : class RouteConfigUpdateReceiverImpl : public RouteConfigUpdateReceiver { 13 : public: 14 : RouteConfigUpdateReceiverImpl(ConfigTraits& config_traits, ProtoTraits& proto_traits, 15 : Server::Configuration::ServerFactoryContext& factory_context); 16 : 17 100 : uint64_t getHash(const Protobuf::Message& rc) const { return MessageUtil::hash(rc); } 18 100 : bool checkHash(uint64_t new_hash) const { return (new_hash != last_config_hash_); } 19 36 : void updateHash(uint64_t hash) { last_config_hash_ = hash; } 20 : void updateConfig(std::unique_ptr<Protobuf::Message>&& route_config_proto); 21 : void onUpdateCommon(const std::string& version_info); 22 : 23 : // RouteConfigUpdateReceiver 24 : bool onRdsUpdate(const Protobuf::Message& rc, const std::string& version_info) override; 25 : 26 0 : uint64_t configHash() const override { return last_config_hash_; } 27 : const absl::optional<RouteConfigProvider::ConfigInfo>& configInfo() const override; 28 72 : const Protobuf::Message& protobufConfiguration() const override { return *route_config_proto_; } 29 86 : ConfigConstSharedPtr parsedConfiguration() const override { return config_; } 30 36 : SystemTime lastUpdated() const override { return last_updated_; } 31 : 32 : private: 33 : ConfigTraits& config_traits_; 34 : ProtoTraits& proto_traits_; 35 : Server::Configuration::ServerFactoryContext& factory_context_; 36 : TimeSource& time_source_; 37 : ProtobufTypes::MessagePtr route_config_proto_; 38 : uint64_t last_config_hash_{0ull}; 39 : SystemTime last_updated_; 40 : absl::optional<RouteConfigProvider::ConfigInfo> config_info_; 41 : ConfigConstSharedPtr config_; 42 : }; 43 : 44 : } // namespace Rds 45 : } // namespace Envoy