Line data Source code
1 : #pragma once 2 : 3 : #include <memory> 4 : 5 : #include "envoy/common/pure.h" 6 : #include "envoy/common/time.h" 7 : #include "envoy/rds/route_config_provider.h" 8 : 9 : #include "absl/types/optional.h" 10 : 11 : namespace Envoy { 12 : namespace Rds { 13 : 14 : /** 15 : * A primitive that keeps track of updates to a RouteConfiguration. 16 : */ 17 : class RouteConfigUpdateReceiver { 18 : public: 19 100 : virtual ~RouteConfigUpdateReceiver() = default; 20 : 21 : /** 22 : * Called on updates via RDS. 23 : * @param rc supplies the RouteConfiguration. 24 : * @param version_info supplies RouteConfiguration version. 25 : * @return bool whether the hash of the new config has been different than 26 : * the hash of the current one and RouteConfiguration has been updated. 27 : * @throw EnvoyException if the new config is invalid and can't be applied. 28 : */ 29 : virtual bool onRdsUpdate(const Protobuf::Message& rc, const std::string& version_info) PURE; 30 : 31 : /** 32 : * @return uint64_t the hash value of RouteConfiguration. 33 : */ 34 : virtual uint64_t configHash() const PURE; 35 : 36 : /** 37 : * @return absl::optional<RouteConfigProvider::ConfigInfo> containing an instance of 38 : * RouteConfigProvider::ConfigInfo if RouteConfiguration has been updated at least once. Otherwise 39 : * returns an empty absl::optional<RouteConfigProvider::ConfigInfo>. 40 : */ 41 : virtual const absl::optional<RouteConfigProvider::ConfigInfo>& configInfo() const PURE; 42 : 43 : /** 44 : * @return Protobuf::Message& current RouteConfiguration. 45 : */ 46 : virtual const Protobuf::Message& protobufConfiguration() const PURE; 47 : 48 : /** 49 : * @return ConfigConstSharedPtr a parsed and validated copy of current RouteConfiguration. 50 : * @see protobufConfiguration() 51 : */ 52 : virtual ConfigConstSharedPtr parsedConfiguration() const PURE; 53 : 54 : /** 55 : * @return SystemTime the time of the last update. 56 : */ 57 : virtual SystemTime lastUpdated() const PURE; 58 : }; 59 : 60 : using RouteConfigUpdatePtr = std::unique_ptr<RouteConfigUpdateReceiver>; 61 : 62 : } // namespace Rds 63 : } // namespace Envoy