1
#include "source/extensions/bootstrap/wasm/config.h"
2

            
3
#include "envoy/registry/registry.h"
4
#include "envoy/server/factory_context.h"
5

            
6
#include "source/common/common/empty_string.h"
7
#include "source/common/config/datasource.h"
8
#include "source/common/protobuf/utility.h"
9
#include "source/extensions/common/wasm/wasm.h"
10

            
11
namespace Envoy {
12
namespace Extensions {
13
namespace Bootstrap {
14
namespace Wasm {
15

            
16
13
void WasmServiceExtension::onServerInitialized(Server::Instance&) { createWasm(context_); }
17

            
18
13
void WasmServiceExtension::createWasm(Server::Configuration::ServerFactoryContext& context) {
19
13
  plugin_config_ = std::make_unique<Common::Wasm::PluginConfig>(
20
13
      config_.config(), context, context.scope(), context.initManager(),
21
13
      envoy::config::core::v3::TrafficDirection::UNSPECIFIED, /*metadata=*/nullptr,
22
13
      config_.singleton());
23
13
}
24

            
25
Server::BootstrapExtensionPtr
26
WasmFactory::createBootstrapExtension(const Protobuf::Message& config,
27
13
                                      Server::Configuration::ServerFactoryContext& context) {
28
13
  const auto& typed_config =
29
13
      MessageUtil::downcastAndValidate<const envoy::extensions::wasm::v3::WasmService&>(
30
13
          config, context.messageValidationContext().staticValidationVisitor());
31
13
  context.api().customStatNamespaces().registerStatNamespace(
32
13
      Extensions::Common::Wasm::CustomStatNamespace);
33
13
  return std::make_unique<WasmServiceExtension>(typed_config, context);
34
13
}
35

            
36
// /**
37
//  * Static registration for the wasm factory. @see RegistryFactory.
38
//  */
39
REGISTER_FACTORY(WasmFactory, Server::Configuration::BootstrapExtensionFactory);
40

            
41
} // namespace Wasm
42
} // namespace Bootstrap
43
} // namespace Extensions
44
} // namespace Envoy