From f6e39ad47fe4345b9525148cdece8ad43bedc840 Mon Sep 17 00:00:00 2001 From: Gabriele Santomaggio Date: Thu, 25 Feb 2021 15:19:45 +0100 Subject: [PATCH] add setDynamicdata method --- bazel/repository_locations.bzl | 6 +++--- source/extensions/common/wasm/context.cc | 16 ++++++++++++++++ source/extensions/common/wasm/context.h | 2 ++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/bazel/repository_locations.bzl b/bazel/repository_locations.bzl index d914c9761535..735859d4a1ba 100644 --- a/bazel/repository_locations.bzl +++ b/bazel/repository_locations.bzl @@ -921,10 +921,10 @@ REPOSITORY_LOCATIONS_SPEC = dict( project_name = "WebAssembly for Proxies (C++ host implementation)", project_desc = "WebAssembly for Proxies (C++ host implementation)", project_url = "https://github.com/proxy-wasm/proxy-wasm-cpp-host", - version = "d1a2a7db59a72edacc9a6286b64280b72767d2d0", - sha256 = "3e81235c963291bd01f9425ed6e34d6b44ca0adc9f281b0cafc5cba6ad3bcc6d", + version = "dcfce2c319b26bd9109edd905d69f35e0b7cbc8e", + sha256 = "7ef0b220769b7ba536df40954451cb333822053e7030eff194e4a911472dc7d2", strip_prefix = "proxy-wasm-cpp-host-{version}", - urls = ["https://github.com/proxy-wasm/proxy-wasm-cpp-host/archive/{version}.tar.gz"], + urls = ["https://github.com/Gsantomaggio/proxy-wasm-cpp-host/archive/{version}.tar.gz"], use_category = ["dataplane_ext"], extensions = [ "envoy.access_loggers.wasm", diff --git a/source/extensions/common/wasm/context.cc b/source/extensions/common/wasm/context.cc index aab2d7a7d76a..e827f5147f1f 100644 --- a/source/extensions/common/wasm/context.cc +++ b/source/extensions/common/wasm/context.cc @@ -1120,6 +1120,22 @@ const Network::Connection* Context::getConnection() const { return nullptr; } +WasmResult Context::setDynamicdata(absl::string_view path, absl::string_view value) { + auto* stream_info = getRequestStreamInfo(); + if (!stream_info) { + return WasmResult::NotFound; + } + std::string key; + absl::StrAppend(&key, path); + ProtobufWkt::Struct metadata_val; + // auto& fields_a = *metadata_val.mutable_fields(); + std::string metadata_value; + absl::StrAppend(&metadata_value, value); + + stream_info->setDynamicMetadata(key, metadata_val); + return WasmResult::Ok; +} + WasmResult Context::setProperty(absl::string_view path, absl::string_view value) { auto* stream_info = getRequestStreamInfo(); if (!stream_info) { diff --git a/source/extensions/common/wasm/context.h b/source/extensions/common/wasm/context.h index f6ef9384bb3b..3648ae713247 100644 --- a/source/extensions/common/wasm/context.h +++ b/source/extensions/common/wasm/context.h @@ -218,6 +218,8 @@ class Context : public proxy_wasm::ContextBase, // State accessors WasmResult getProperty(absl::string_view path, std::string* result) override; WasmResult setProperty(absl::string_view path, absl::string_view value) override; + WasmResult setDynamicdata(absl::string_view path, absl::string_view value) override; + WasmResult declareProperty(absl::string_view path, Filters::Common::Expr::CelStatePrototypeConstPtr state_prototype);