/proc/self/cwd/source/extensions/filters/network/wasm/wasm_filter.cc
Line | Count | Source (jump to first uncovered line) |
1 | | #include "source/extensions/filters/network/wasm/wasm_filter.h" |
2 | | |
3 | | namespace Envoy { |
4 | | namespace Extensions { |
5 | | namespace NetworkFilters { |
6 | | namespace Wasm { |
7 | | |
8 | | FilterConfig::FilterConfig(const envoy::extensions::filters::network::wasm::v3::Wasm& config, |
9 | | Server::Configuration::FactoryContext& context) |
10 | | : tls_slot_(ThreadLocal::TypedSlot<Common::Wasm::PluginHandleSharedPtrThreadLocal>::makeUnique( |
11 | 0 | context.threadLocal())) { |
12 | 0 | const auto plugin = std::make_shared<Common::Wasm::Plugin>( |
13 | 0 | config.config(), context.direction(), context.localInfo(), &context.listenerMetadata()); |
14 | |
|
15 | 0 | auto callback = [plugin, this](Common::Wasm::WasmHandleSharedPtr base_wasm) { |
16 | | // NB: the Slot set() call doesn't complete inline, so all arguments must outlive this call. |
17 | 0 | tls_slot_->set([base_wasm, plugin](Event::Dispatcher& dispatcher) { |
18 | 0 | return std::make_shared<PluginHandleSharedPtrThreadLocal>( |
19 | 0 | Common::Wasm::getOrCreateThreadLocalPlugin(base_wasm, plugin, dispatcher)); |
20 | 0 | }); |
21 | 0 | }; |
22 | |
|
23 | 0 | if (!Common::Wasm::createWasm(plugin, context.scope().createScope(""), context.clusterManager(), |
24 | 0 | context.initManager(), context.mainThreadDispatcher(), |
25 | 0 | context.api(), context.lifecycleNotifier(), remote_data_provider_, |
26 | 0 | std::move(callback))) { |
27 | 0 | throw Common::Wasm::WasmException( |
28 | 0 | fmt::format("Unable to create Wasm network filter {}", plugin->name_)); |
29 | 0 | } |
30 | 0 | } |
31 | | |
32 | | } // namespace Wasm |
33 | | } // namespace NetworkFilters |
34 | | } // namespace Extensions |
35 | | } // namespace Envoy |