Line data Source code
1 : #pragma once 2 : 3 : #include "envoy/common/optref.h" 4 : #include "envoy/common/pure.h" 5 : #include "envoy/config/extension_config_provider.h" 6 : #include "envoy/network/filter.h" 7 : 8 : #include "source/common/protobuf/protobuf.h" 9 : 10 : #include "absl/types/optional.h" 11 : 12 : namespace Envoy { 13 : namespace Config { 14 : 15 : using ConfigAppliedCb = std::function<void()>; 16 : 17 : class DynamicExtensionConfigProviderBase { 18 : public: 19 0 : virtual ~DynamicExtensionConfigProviderBase() = default; 20 : 21 : /** 22 : * Update the provider with a new configuration. This interface accepts proto rather than a 23 : * factory callback so that it can be generic over factory types. If instantiating the factory 24 : * throws, it should only do so on the main thread, before any changes are applied to workers. 25 : * @param config is the new configuration. It is expected that the configuration has already been 26 : * validated. 27 : * @param version_info is the version of the new extension configuration. 28 : * @param cb the continuation callback for a completed configuration application on all threads. 29 : * @return an absl status indicating if a non-exception-throwing error was encountered. 30 : */ 31 : virtual absl::Status onConfigUpdate(const Protobuf::Message& config, 32 : const std::string& version_info, 33 : ConfigAppliedCb applied_on_all_threads) PURE; 34 : 35 : /** 36 : * Removes the current configuration from the provider. 37 : * @param cb the continuation callback for a completed configuration application on all threads. 38 : */ 39 : virtual void onConfigRemoved(ConfigAppliedCb applied_on_all_threads) PURE; 40 : 41 : /** 42 : * Applies the default configuration if one is set, otherwise does nothing. 43 : */ 44 : virtual void applyDefaultConfiguration() PURE; 45 : /** 46 : * Return Network::ListenerFilterMatcherSharedPtr& the listener filter matcher. 47 : */ 48 : virtual const Network::ListenerFilterMatcherSharedPtr& getListenerFilterMatcher() PURE; 49 : }; 50 : 51 : template <class FactoryCallback> 52 : class DynamicExtensionConfigProvider : public DynamicExtensionConfigProviderBase, 53 : public ExtensionConfigProvider<FactoryCallback> {}; 54 : 55 : } // namespace Config 56 : } // namespace Envoy