/proc/self/cwd/source/extensions/bootstrap/wasm/config.h
Line | Count | Source (jump to first uncovered line) |
1 | | #pragma once |
2 | | |
3 | | #include "envoy/common/pure.h" |
4 | | #include "envoy/extensions/wasm/v3/wasm.pb.h" |
5 | | #include "envoy/extensions/wasm/v3/wasm.pb.validate.h" |
6 | | #include "envoy/server/bootstrap_extension_config.h" |
7 | | #include "envoy/server/filter_config.h" |
8 | | #include "envoy/server/instance.h" |
9 | | |
10 | | #include "source/common/protobuf/protobuf.h" |
11 | | #include "source/extensions/common/wasm/remote_async_datasource.h" |
12 | | #include "source/extensions/common/wasm/wasm.h" |
13 | | |
14 | | namespace Envoy { |
15 | | namespace Extensions { |
16 | | namespace Bootstrap { |
17 | | namespace Wasm { |
18 | | |
19 | | using Common::Wasm::PluginHandleSharedPtrThreadLocal; |
20 | | using Envoy::Extensions::Common::Wasm::PluginHandleSharedPtr; |
21 | | using Envoy::Extensions::Common::Wasm::PluginSharedPtr; |
22 | | |
23 | | class WasmService { |
24 | | public: |
25 | | WasmService(PluginSharedPtr plugin, PluginHandleSharedPtr singleton) |
26 | 0 | : plugin_(plugin), singleton_(std::move(singleton)) {} |
27 | | WasmService(PluginSharedPtr plugin, |
28 | | ThreadLocal::TypedSlotPtr<PluginHandleSharedPtrThreadLocal>&& tls_slot) |
29 | 0 | : plugin_(plugin), tls_slot_(std::move(tls_slot)) {} |
30 | | |
31 | | private: |
32 | | PluginSharedPtr plugin_; |
33 | | PluginHandleSharedPtr singleton_; |
34 | | ThreadLocal::TypedSlotPtr<PluginHandleSharedPtrThreadLocal> tls_slot_; |
35 | | }; |
36 | | |
37 | | using WasmServicePtr = std::unique_ptr<WasmService>; |
38 | | |
39 | | class WasmFactory : public Server::Configuration::BootstrapExtensionFactory { |
40 | | public: |
41 | | ~WasmFactory() override = default; |
42 | 2.50k | std::string name() const override { return "envoy.bootstrap.wasm"; } |
43 | | Server::BootstrapExtensionPtr |
44 | | createBootstrapExtension(const Protobuf::Message& config, |
45 | | Server::Configuration::ServerFactoryContext& context) override; |
46 | 1 | ProtobufTypes::MessagePtr createEmptyConfigProto() override { |
47 | 1 | return std::make_unique<envoy::extensions::wasm::v3::WasmService>(); |
48 | 1 | } |
49 | | }; |
50 | | |
51 | | class WasmServiceExtension : public Server::BootstrapExtension, Logger::Loggable<Logger::Id::wasm> { |
52 | | public: |
53 | | WasmServiceExtension(const envoy::extensions::wasm::v3::WasmService& config, |
54 | | Server::Configuration::ServerFactoryContext& context) |
55 | 0 | : config_(config), context_(context) {} |
56 | 0 | WasmService& wasmService() { |
57 | 0 | ASSERT(wasm_service_ != nullptr); |
58 | 0 | return *wasm_service_; |
59 | 0 | } |
60 | | void onServerInitialized() override; |
61 | | |
62 | | private: |
63 | | void createWasm(Server::Configuration::ServerFactoryContext& context); |
64 | | |
65 | | envoy::extensions::wasm::v3::WasmService config_; |
66 | | Server::Configuration::ServerFactoryContext& context_; |
67 | | WasmServicePtr wasm_service_; |
68 | | RemoteAsyncDataProviderPtr remote_data_provider_; |
69 | | }; |
70 | | |
71 | | } // namespace Wasm |
72 | | } // namespace Bootstrap |
73 | | } // namespace Extensions |
74 | | } // namespace Envoy |