Line data Source code
1 : #pragma once 2 : 3 : #include <string> 4 : 5 : #include "envoy/config/config_provider.h" 6 : #include "envoy/server/filter_config.h" 7 : 8 : #include "source/common/protobuf/protobuf.h" 9 : 10 : namespace Envoy { 11 : namespace Config { 12 : 13 : /** 14 : * A ConfigProvider manager which instantiates static and dynamic (xDS) providers. 15 : * 16 : * ConfigProvider objects are owned by the caller of the 17 : * createXdsConfigProvider()/createStaticConfigProvider() functions. The ConfigProviderManager holds 18 : * raw pointers to those objects. 19 : * 20 : * Configuration implementations returned by ConfigProvider::config() are immutable, which allows 21 : * them to share the underlying objects such as config protos and subscriptions (for dynamic 22 : * providers) without synchronization related performance penalties. This enables linear memory 23 : * growth based on the size of the configuration set, regardless of the number of threads/objects 24 : * that must hold a reference/pointer to them. 25 : */ 26 : class ConfigProviderManager { 27 : public: 28 : class OptionalArg { 29 : public: 30 0 : virtual ~OptionalArg() = default; 31 : }; 32 : 33 : class NullOptionalArg : public OptionalArg { 34 : public: 35 : NullOptionalArg() = default; 36 : ~NullOptionalArg() override = default; 37 : }; 38 : 39 96 : virtual ~ConfigProviderManager() = default; 40 : 41 : /** 42 : * Returns a dynamic ConfigProvider which receives configuration via an xDS API. 43 : * A shared ownership model is used, such that the underlying subscription, config proto 44 : * and Config are shared amongst all providers relying on the same config source. 45 : * @param config_source_proto supplies the proto containing the xDS API configuration. 46 : * @param factory_context is the context to use for the provider. 47 : * @param init_manager is the Init::Manager to use for the provider. 48 : * @param stat_prefix supplies the prefix to use for statistics. 49 : * @param optarg supplies an optional argument with data specific to the concrete class. 50 : * @return ConfigProviderPtr a newly allocated dynamic config provider which shares underlying 51 : * data structures with other dynamic providers configured with the same 52 : * API source. 53 : */ 54 : virtual ConfigProviderPtr 55 : createXdsConfigProvider(const Protobuf::Message& config_source_proto, 56 : Server::Configuration::ServerFactoryContext& factory_context, 57 : Init::Manager& init_manager, const std::string& stat_prefix, 58 : const OptionalArg& optarg) PURE; 59 : 60 : /** 61 : * Returns a ConfigProvider associated with a statically specified configuration. 62 : * @param config_proto supplies the configuration proto. 63 : * @param factory_context is the context to use for the provider. 64 : * @param optarg supplies an optional argument with data specific to the concrete class. 65 : * @return ConfigProviderPtr a newly allocated static config provider. 66 : */ 67 : virtual ConfigProviderPtr 68 : createStaticConfigProvider(const Protobuf::Message& config_proto, 69 : Server::Configuration::ServerFactoryContext& factory_context, 70 0 : const OptionalArg& optarg) { 71 0 : UNREFERENCED_PARAMETER(config_proto); 72 0 : UNREFERENCED_PARAMETER(factory_context); 73 0 : UNREFERENCED_PARAMETER(optarg); 74 0 : return nullptr; 75 0 : } 76 : 77 : /** 78 : * Returns a ConfigProvider associated with a statically specified configuration. This is intended 79 : * to be used when a set of configuration protos is required to build the full configuration. 80 : * @param config_protos supplies a vector of configuration protos. 81 : * @param factory_context is the context to use for the provider. 82 : * @param optarg supplies an optional argument with data specific to the concrete class. 83 : * @return ConfigProviderPtr a newly allocated static config provider. 84 : */ 85 : virtual ConfigProviderPtr 86 : createStaticConfigProvider(ProtobufTypes::ConstMessagePtrVector&& config_protos, 87 : Server::Configuration::ServerFactoryContext& factory_context, 88 0 : const OptionalArg& optarg) { 89 0 : UNREFERENCED_PARAMETER(config_protos); 90 0 : UNREFERENCED_PARAMETER(factory_context); 91 0 : UNREFERENCED_PARAMETER(optarg); 92 0 : return nullptr; 93 0 : } 94 : }; 95 : 96 : } // namespace Config 97 : } // namespace Envoy