Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 0 additions & 39 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,6 @@ cc_library(
],
)

# TODO: remove when dependent projects have been upgraded.
cc_library(
name = "lib14",
srcs = glob(
["src/**/*.cc"],
exclude = [
"src/**/wavm*",
"src/**/v8*",
],
) + glob(["src/**/*.h"]),
copts = [
"-std=c++14",
"-DWITHOUT_ZLIB=1",
],
deps = [
":include",
"@com_google_absl//absl/base",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/types:optional",
"@com_google_protobuf//:protobuf_lite",
"@proxy_wasm_cpp_sdk//:api_lib",
],
)

cc_test(
name = "wasm_vm_test",
srcs = ["wasm_vm_test.cc"],
Expand All @@ -70,18 +46,3 @@ cc_test(
"@com_google_googletest//:gtest_main",
],
)

# TODO: remove when dependent projects have been upgraded.
cc_test(
name = "context_14_test",
srcs = ["context_test.cc"],
copts = ["-std=c++14"],
deps = [
":include",
"@com_google_absl//absl/base",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/types:optional",
"@com_google_googletest//:gtest",
"@com_google_googletest//:gtest_main",
],
)
2 changes: 1 addition & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")

git_repository(
name = "proxy_wasm_cpp_sdk",
commit = "35163bbf32fccfbde7b95d909a392dc1dc562596",
commit = "aea22d74befc1bb34d2b8c35f0558e53ba5d1cd5",
remote = "https://github.com/proxy-wasm/proxy-wasm-cpp-sdk",
)

Expand Down
7 changes: 4 additions & 3 deletions context_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ namespace {

class Context : public ContextBase {
public:
Context(std::function<void(string_view s)> error_function) : error_function_(error_function) {}
void error(string_view message) { error_function_(message); }
Context(std::function<void(std::string_view s)> error_function)
: error_function_(error_function) {}
void error(std::string_view message) { error_function_(message); }

private:
std::function<void(string_view s)> error_function_;
std::function<void(std::string_view s)> error_function_;
};

TEST(Context, IncludeParses) {}
Expand Down
46 changes: 0 additions & 46 deletions include/proxy-wasm/compat.h

This file was deleted.

78 changes: 40 additions & 38 deletions include/proxy-wasm/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include <memory>
#include <vector>

#include "include/proxy-wasm/compat.h"
#include "include/proxy-wasm/context_interface.h"

namespace proxy_wasm {
Expand All @@ -47,8 +46,8 @@ class WasmVm;
* @param fail_open if true the plugin will pass traffic as opposed to close all streams.
*/
struct PluginBase {
PluginBase(string_view name, string_view root_id, string_view vm_id, string_view runtime,
string_view plugin_configuration, bool fail_open)
PluginBase(std::string_view name, std::string_view root_id, std::string_view vm_id,
std::string_view runtime, std::string_view plugin_configuration, bool fail_open)
: name_(std::string(name)), root_id_(std::string(root_id)), vm_id_(std::string(vm_id)),
runtime_(std::string(runtime)), plugin_configuration_(plugin_configuration),
fail_open_(fail_open) {}
Expand Down Expand Up @@ -80,7 +79,8 @@ struct BufferBase : public BufferInterface {
}
WasmResult copyTo(WasmBase *wasm, size_t start, size_t length, uint64_t ptr_ptr,
uint64_t size_ptr) const override;
WasmResult copyFrom(size_t /* start */, size_t /* length */, string_view /* data */) override {
WasmResult copyFrom(size_t /* start */, size_t /* length */,
std::string_view /* data */) override {
// Setting a string buffer not supported (no use case).
return WasmResult::BadArgument;
}
Expand All @@ -89,7 +89,7 @@ struct BufferBase : public BufferInterface {
data_ = "";
owned_data_ = nullptr;
}
BufferBase *set(string_view data) {
BufferBase *set(std::string_view data) {
clear();
data_ = data;
return this;
Expand All @@ -102,7 +102,7 @@ struct BufferBase : public BufferInterface {
}

protected:
string_view data_;
std::string_view data_;
std::unique_ptr<char[]> owned_data_;
uint32_t owned_data_size_;
};
Expand Down Expand Up @@ -158,8 +158,8 @@ class ContextBase : public RootInterface,
}
return parent;
}
string_view root_id() const { return isRootContext() ? root_id_ : plugin_->root_id_; }
string_view log_prefix() const {
std::string_view root_id() const { return isRootContext() ? root_id_ : plugin_->root_id_; }
std::string_view log_prefix() const {
return isRootContext() ? root_log_prefix_ : plugin_->log_prefix();
}
WasmVm *wasmVm() const;
Expand Down Expand Up @@ -212,7 +212,7 @@ class ContextBase : public RootInterface,
void onGrpcReceiveTrailingMetadata(GrpcToken token, uint32_t trailers) override;
void onGrpcClose(GrpcToken token, GrpcStatusCode status_code) override;

void error(string_view message) override {
void error(std::string_view message) override {
std::cerr << message << "\n";
abort();
}
Expand All @@ -226,7 +226,7 @@ class ContextBase : public RootInterface,
//
// General Callbacks.
//
WasmResult log(uint32_t /* level */, string_view /* message */) override {
WasmResult log(uint32_t /* level */, std::string_view /* message */) override {
return unimplemented();
}
uint32_t getLogLevel() override { return static_cast<uint32_t>(LogLevel::info); }
Expand All @@ -238,7 +238,7 @@ class ContextBase : public RootInterface,
t += tpe.tv_nsec;
return t;
}
std::pair<uint32_t, string_view> getStatus() override {
std::pair<uint32_t, std::string_view> getStatus() override {
unimplemented();
return std::make_pair(1, "unimplmemented");
}
Expand All @@ -255,21 +255,21 @@ class ContextBase : public RootInterface,
}

// HTTP
WasmResult httpCall(string_view /* target */, const Pairs & /*request_headers */,
string_view /* request_body */, const Pairs & /* request_trailers */,
WasmResult httpCall(std::string_view /* target */, const Pairs & /*request_headers */,
std::string_view /* request_body */, const Pairs & /* request_trailers */,
int /* timeout_millisconds */, uint32_t * /* token_ptr */) override {
return unimplemented();
}

// gRPC
WasmResult grpcCall(string_view /* grpc_service */, string_view /* service_name */,
string_view /* method_name */, const Pairs & /* initial_metadata */,
string_view /* request */, std::chrono::milliseconds /* timeout */,
WasmResult grpcCall(std::string_view /* grpc_service */, std::string_view /* service_name */,
std::string_view /* method_name */, const Pairs & /* initial_metadata */,
std::string_view /* request */, std::chrono::milliseconds /* timeout */,
GrpcToken * /* token_ptr */) override {
return unimplemented();
}
WasmResult grpcStream(string_view /* grpc_service */, string_view /* service_name */,
string_view /* method_name */, const Pairs & /* initial_metadata */,
WasmResult grpcStream(std::string_view /* grpc_service */, std::string_view /* service_name */,
std::string_view /* method_name */, const Pairs & /* initial_metadata */,
GrpcToken * /* token_ptr */) override {
return unimplemented();
}
Expand All @@ -279,13 +279,13 @@ class ContextBase : public RootInterface,
WasmResult grpcCancel(uint32_t /* token */) override { // cancel on call, reset on stream.
return unimplemented();
}
WasmResult grpcSend(uint32_t /* token */, string_view /* message */,
WasmResult grpcSend(uint32_t /* token */, std::string_view /* message */,
bool /* end_stream */) override { // stream only
return unimplemented();
}

// Metrics
WasmResult defineMetric(uint32_t /* type */, string_view /* name */,
WasmResult defineMetric(uint32_t /* type */, std::string_view /* name */,
uint32_t * /* metric_id_ptr */) override {
return unimplemented();
}
Expand All @@ -300,43 +300,44 @@ class ContextBase : public RootInterface,
}

// Properties
WasmResult getProperty(string_view /* path */, std::string * /* result */) override {
WasmResult getProperty(std::string_view /* path */, std::string * /* result */) override {
return unimplemented();
}
WasmResult setProperty(string_view /* key */, string_view /* serialized_value */) override {
WasmResult setProperty(std::string_view /* key */,
std::string_view /* serialized_value */) override {
return unimplemented();
}

// Continue
WasmResult continueStream(WasmStreamType /* stream_type */) override { return unimplemented(); }
WasmResult closeStream(WasmStreamType /* stream_type */) override { return unimplemented(); }
WasmResult sendLocalResponse(uint32_t /* response_code */, string_view /* body_text */,
WasmResult sendLocalResponse(uint32_t /* response_code */, std::string_view /* body_text */,
Pairs /* additional_headers */, GrpcStatusCode /* grpc_status */,
string_view /* details */) override {
std::string_view /* details */) override {
return unimplemented();
}
void failStream(WasmStreamType stream_type) override { closeStream(stream_type); }

// Shared Data
WasmResult getSharedData(string_view key,
WasmResult getSharedData(std::string_view key,
std::pair<std::string, uint32_t /* cas */> *data) override;
WasmResult setSharedData(string_view key, string_view value, uint32_t cas) override;
WasmResult setSharedData(std::string_view key, std::string_view value, uint32_t cas) override;

// Shared Queue
WasmResult registerSharedQueue(string_view queue_name,
WasmResult registerSharedQueue(std::string_view queue_name,
SharedQueueDequeueToken *token_ptr) override;
WasmResult lookupSharedQueue(string_view vm_id, string_view queue_name,
WasmResult lookupSharedQueue(std::string_view vm_id, std::string_view queue_name,
SharedQueueEnqueueToken *token) override;
WasmResult dequeueSharedQueue(uint32_t token, std::string *data) override;
WasmResult enqueueSharedQueue(uint32_t token, string_view value) override;
WasmResult enqueueSharedQueue(uint32_t token, std::string_view value) override;

// Header/Trailer/Metadata Maps
WasmResult addHeaderMapValue(WasmHeaderMapType /* type */, string_view /* key */,
string_view /* value */) override {
WasmResult addHeaderMapValue(WasmHeaderMapType /* type */, std::string_view /* key */,
std::string_view /* value */) override {
return unimplemented();
}
WasmResult getHeaderMapValue(WasmHeaderMapType /* type */, string_view /* key */,
string_view * /*result */) override {
WasmResult getHeaderMapValue(WasmHeaderMapType /* type */, std::string_view /* key */,
std::string_view * /*result */) override {
return unimplemented();
}
WasmResult getHeaderMapPairs(WasmHeaderMapType /* type */, Pairs * /* result */) override {
Expand All @@ -346,11 +347,12 @@ class ContextBase : public RootInterface,
return unimplemented();
}

WasmResult removeHeaderMapValue(WasmHeaderMapType /* type */, string_view /* key */) override {
WasmResult removeHeaderMapValue(WasmHeaderMapType /* type */,
std::string_view /* key */) override {
return unimplemented();
}
WasmResult replaceHeaderMapValue(WasmHeaderMapType /* type */, string_view /* key */,
string_view /* value */) override {
WasmResult replaceHeaderMapValue(WasmHeaderMapType /* type */, std::string_view /* key */,
std::string_view /* value */) override {
return unimplemented();
}

Expand All @@ -362,7 +364,7 @@ class ContextBase : public RootInterface,
friend class WasmBase;

void initializeRootBase(WasmBase *wasm, std::shared_ptr<PluginBase> plugin);
std::string makeRootLogPrefix(string_view vm_id) const;
std::string makeRootLogPrefix(std::string_view vm_id) const;

WasmBase *wasm_{nullptr};
uint32_t id_{0};
Expand All @@ -384,6 +386,6 @@ class DeferAfterCallActions {
WasmBase *const wasm_;
};

uint32_t resolveQueueForTest(string_view vm_id, string_view queue_name);
uint32_t resolveQueueForTest(std::string_view vm_id, std::string_view queue_name);

} // namespace proxy_wasm
Loading