Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make using varients of protobuf easier. #17

Merged
merged 2 commits into from May 18, 2020
Merged

Make using varients of protobuf easier. #17

merged 2 commits into from May 18, 2020

Conversation

jplevyak
Copy link
Contributor

@jplevyak jplevyak commented May 4, 2020

Signed-off-by: John Plevyak jplevyak@gmail.com

Signed-off-by: John Plevyak <jplevyak@gmail.com>
@jplevyak jplevyak requested a review from PiotrSikora May 4, 2020 22:15
@jplevyak
Copy link
Contributor Author

jplevyak commented May 4, 2020

This makes it possible to compile with full, lite or no protobuf support.

proxy_wasm_api.h Outdated Show resolved Hide resolved
Signed-off-by: John Plevyak <jplevyak@gmail.com>
@jplevyak jplevyak requested a review from lizan May 5, 2020 00:00
// NOLINT(namespace-envoy)

#pragma once
#define PROXY_WASM_PROTOBUF_FULL 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is defined twice, once in copts and in once the header file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, yes I did. This is unfortunately AFAICT it is required because bazel doesn't seem to work the way one would reasonably expect it to work. The copts doesn't seem to be contagious to targets which depend on a a header from the library which defines the copt. Consequently in order to get the #define to actually impact the header when it is included in another target, ,e.g. gcpc_call_cpp.cc in test/extensions/filters/http/wasm/test_data, on needs to add it to that target or conversely one could use a header which includes it such as here.

That said, my understanding of bazel is perhaps not what it should be and if you have a better solution I am all ears.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, copts are not propagated "upwards", so having this defined in headers is fine... With that said, is there any reason to have it defined in copts as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want to add the copts in the wasm_cc_binary target because that is messy. This way I can conceal that mess in the proxy-wasm-cpp-sdk library proper.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need copts in either place, just having this header should be enough.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Erm, I meant that you should remove define from copts in :proxy_wasm_intrinsics_lite and : proxy_wasm_intrinsics_full targets.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then I have to add it at the higher level in the wasm_cc_binary targets which is messy and inconvenient. I can't include a different header in the proxy_wasm_intrinsics.cc file without having a #define so I need two targets for it with different copts. If you have a way to get this to work I would like to here it but I tried several ways and this was the best way I could find to get bazel to do what I want. I suppose I could build wasm_cc_binary_full and wasm_cc_binary_lite, but that doesn't seem to be an improvement either.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wasm_cc_binary_full and wasm_cc_binary_lite sound messy, let's not do that.

I still think that copts is not necessary, but it's also not a blocker, so feel free to merge this as-is.

// NOLINT(namespace-envoy)

#pragma once
#define PROXY_WASM_PROTOBUF_LITE 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(same here)

@@ -335,6 +335,7 @@ class RootContext : public ContextBase {
uint32_t timeout_milliseconds, HttpCallCallback callback);
// NB: the message is the response if status == OK and an error message
// otherwise. Returns false on setup error.
#ifdef PROXY_WASM_PROTOBUF
WasmResult grpcSimpleCall(StringView service, StringView service_name, StringView method_name,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about other gRPC functions? i.e. open_stream, send_message, cancel, and close? Shouldn't we be disabling them as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could. I was hoping to talk to others who might be interested in using say flatbuffers with gRPC. They might have alternative solutions for the functions which depend directly on MessageLite.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd err on the of side having good support for features that we support, and not having support for features that we don't officially support, i.e. I'm 100% for adding back other functions iff someone adds support for gRPC with flatbuffers, but since we don't have it yet, I think we should disable reminding gRPC functions when compiled without protobuf.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a bug preventing me from fixing this: envoyproxy/envoy-wasm#508

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gRPC doesn't have to be a protobuf payload, any buffer (string/string_view) should work and Envoy has support of that. But we should turn off those method with protobuf in its signature.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I turned the protobuf ones off, but I didn't provide the "string/string_vew" alternative. WDYT @PiotrSikora ? Should I add those.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably add those (always, not only when building without protobuf), but it's fine to do that in a follow-up PR.

@jplevyak jplevyak requested a review from PiotrSikora May 5, 2020 18:14
@jplevyak
Copy link
Contributor Author

Any updates?

@@ -335,6 +335,7 @@ class RootContext : public ContextBase {
uint32_t timeout_milliseconds, HttpCallCallback callback);
// NB: the message is the response if status == OK and an error message
// otherwise. Returns false on setup error.
#ifdef PROXY_WASM_PROTOBUF
WasmResult grpcSimpleCall(StringView service, StringView service_name, StringView method_name,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably add those (always, not only when building without protobuf), but it's fine to do that in a follow-up PR.

// NOLINT(namespace-envoy)

#pragma once
#define PROXY_WASM_PROTOBUF_FULL 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wasm_cc_binary_full and wasm_cc_binary_lite sound messy, let's not do that.

I still think that copts is not necessary, but it's also not a blocker, so feel free to merge this as-is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants