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
848
  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
   * @return status indicating if the config was successfully removed.
39
   */
40
  virtual absl::Status onConfigRemoved(ConfigAppliedCb applied_on_all_threads) PURE;
41

            
42
  /**
43
   * Applies the default configuration if one is set, otherwise does nothing.
44
   */
45
  virtual absl::Status applyDefaultConfiguration() PURE;
46
  /**
47
   * Return Network::ListenerFilterMatcherSharedPtr& the listener filter matcher.
48
   */
49
  virtual const Network::ListenerFilterMatcherSharedPtr& getListenerFilterMatcher() PURE;
50
};
51

            
52
template <class FactoryCallback>
53
class DynamicExtensionConfigProvider : public DynamicExtensionConfigProviderBase,
54
                                       public ExtensionConfigProvider<FactoryCallback> {};
55

            
56
} // namespace Config
57
} // namespace Envoy