1
#pragma once
2

            
3
#include <memory>
4

            
5
#include "envoy/server/factory_context.h"
6
#include "envoy/server/instance.h"
7

            
8
#include "source/common/protobuf/protobuf.h"
9

            
10
namespace Envoy {
11
namespace Server {
12

            
13
/**
14
 * Parent class for bootstrap extensions.
15
 */
16
class BootstrapExtension {
17
public:
18
409
  virtual ~BootstrapExtension() = default;
19

            
20
  /**
21
   * Called when server is done initializing and we have the ServerFactoryContext fully initialized.
22
   */
23
  virtual void onServerInitialized(Server::Instance& server) PURE;
24

            
25
  /**
26
   * Called when the worker thread is initialized.
27
   */
28
  virtual void onWorkerThreadInitialized() PURE;
29
};
30

            
31
using BootstrapExtensionPtr = std::unique_ptr<BootstrapExtension>;
32

            
33
namespace Configuration {
34

            
35
/**
36
 * Implemented for each bootstrap extension and registered via Registry::registerFactory or the
37
 * convenience class RegisterFactory.
38
 */
39
class BootstrapExtensionFactory : public Config::TypedFactory {
40
public:
41
490
  ~BootstrapExtensionFactory() override = default;
42

            
43
  /**
44
   * Create a particular bootstrap extension implementation from a config proto. If the
45
   * implementation is unable to produce a factory with the provided parameters, it should throw an
46
   * EnvoyException. The returned pointer should never be nullptr.
47
   * @param config the custom configuration for this bootstrap extension type.
48
   * @param context is the context to use for the extension. Note that the clusterManager is not
49
   *    yet initialized at this point and **must not** be used.
50
   */
51
  virtual BootstrapExtensionPtr createBootstrapExtension(const Protobuf::Message& config,
52
                                                         ServerFactoryContext& context) PURE;
53

            
54
3387
  std::string category() const override { return "envoy.bootstrap"; }
55
};
56

            
57
} // namespace Configuration
58
} // namespace Server
59
} // namespace Envoy