Line data Source code
1 : #pragma once 2 : 3 : #include <memory> 4 : 5 : #include "envoy/common/time.h" 6 : #include "envoy/rds/config.h" 7 : 8 : #include "source/common/protobuf/protobuf.h" 9 : 10 : #include "absl/types/optional.h" 11 : 12 : namespace Envoy { 13 : namespace Rds { 14 : 15 : /** 16 : * A provider for constant route configurations. 17 : */ 18 : class RouteConfigProvider { 19 : public: 20 : struct ConfigInfo { 21 : // A reference to the currently loaded route configuration. Do not hold this reference beyond 22 : // the caller of configInfo()'s scope. 23 : const Protobuf::Message& config_; 24 : 25 : // The discovery version that supplied this route. This will be set to "" in the case of 26 : // static clusters. 27 : const std::string version_; 28 : }; 29 : 30 418 : virtual ~RouteConfigProvider() = default; 31 : 32 : /** 33 : * @return ConfigConstSharedPtr a route configuration for use during a single request. The 34 : * returned config may be different on a subsequent call, so a new config should be acquired for 35 : * each request flow. 36 : */ 37 : virtual ConfigConstSharedPtr config() const PURE; 38 : 39 : /** 40 : * @return the configuration information for the currently loaded route configuration. Note that 41 : * if the provider has not yet performed an initial configuration load, no information will be 42 : * returned. 43 : */ 44 : virtual const absl::optional<ConfigInfo>& configInfo() const PURE; 45 : 46 : /** 47 : * @return the last time this RouteConfigProvider was updated. Used for config dumps. 48 : */ 49 : virtual SystemTime lastUpdated() const PURE; 50 : 51 : /** 52 : * Callback used to notify RouteConfigProvider about configuration changes. 53 : * @return Status indicating if the call was successful or had graceful error handling. 54 : */ 55 : virtual absl::Status onConfigUpdate() PURE; 56 : }; 57 : 58 : using RouteConfigProviderPtr = std::unique_ptr<RouteConfigProvider>; 59 : using RouteConfigProviderSharedPtr = std::shared_ptr<RouteConfigProvider>; 60 : 61 : } // namespace Rds 62 : } // namespace Envoy