grpc: add a raw (Buffer::Instance) interface#6525
Conversation
Signed-off-by: John Plevyak <jplevyak@gmail.com>
478fd22 to
e8d933d
Compare
lizan
left a comment
There was a problem hiding this comment.
Thanks for working on this! Let's start from some interface level comments.
/wait
Signed-off-by: John Plevyak <jplevyak@gmail.com>
Signed-off-by: John Plevyak <jplevyak@gmail.com>
|
Can I ask a high level probably stupid question: how is this actually going to be used? Where are the raw message bytes going to come from to send and what is the caller going to do with the raw bytes returned? I understand this change in theory but the utility is not clear to me. |
This is going to be used by the WASM extension system. It can also be used by any generic gRPC proxy system. |
|
I believe I have a plan to address the issue of the API:
I'll ping this PR when I am done. Thanx for the comments. |
OK, thanks that makes sense. So basically the WASM code will have the protos compiled in and just use a raw API to make calls. Regarding the latter, Envoy already is a generic gRPC proxy so I'm not sure why this would ever be used in that manner, but agree it seems possible. Since this is targeted towards WASM/plugin can you update the issue description to make that more clear? Also, more generally, @jplevyak @PiotrSikora @lizan @dio is there a design doc on the proposed WASM <-> API bindings? I've been asking for this for a while and would love to review. Thank you. |
|
@jplevyak this seems like a good plan. Please ping me on IM if you want to chat further. The key things to preserve are economy of mechanism and mockability :) |
|
This pull request has been automatically marked as stale because it has not had activity in the last 7 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions! |
Signed-off-by: John Plevyak <jplevyak@gmail.com>
|
I have updated this PR as per the comments. PTAL |
Signed-off-by: John Plevyak <jplevyak@gmail.com>
lizan
left a comment
There was a problem hiding this comment.
A quick skim, will do more review on Monday.
htuch
left a comment
There was a problem hiding this comment.
Great, I think this is the right direction, a few stuctural comments to start.
/wait
Signed-off-by: John Plevyak <jplevyak@gmail.com>
Signed-off-by: John Plevyak <jplevyak@gmail.com>
Signed-off-by: John Plevyak <jplevyak@gmail.com>
htuch
left a comment
There was a problem hiding this comment.
LGTM. Coverage is failing, I know we are having Envoy-wide issues with being right at 97.5% right now, but you might want to see if there is any avoidable regression in this PR.
|
The MacOS and coverage failures seem to be unrelated. lizan do you have any more comments? |
|
/retest |
|
🐴 hold your horses - no failures detected, yet. |
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
|
@jplevyak the coverage is below the threshold, and we're getting TSAN flakes. Can you merge master and try again, plus maybe look to see if you can fill in any trivial coverage stuff missing? This PR is good to go modulo this. |
Signed-off-by: John Plevyak <jplevyak@gmail.com>
Signed-off-by: John Plevyak <jplevyak@gmail.com>
Signed-off-by: John Plevyak <jplevyak@gmail.com>
See envoyproxy#6917 for details. Signed-off-by: John Plevyak <jplevyak@gmail.com>
Signed-off-by: John Plevyak <jplevyak@gmail.com>
|
I think the coverage is in pretty good shape. If there is anything which stands out, please tell me. |
| // lifetime of the Slice(s) exceeds our Buffer::Instance. | ||
| std::vector<grpc::Slice> slices; | ||
| byte_buffer.Dump(&slices); | ||
| if (!byte_buffer.Dump(&slices).ok()) { |
There was a problem hiding this comment.
Is there a way to mock this for testing?
There was a problem hiding this comment.
Even the gRPC library provided by Google doesn't test for Dump failure. Here is the only test:
TEST_F(ByteBufferTest, Dump) {
grpc_slice hello = grpc_slice_from_copied_string(kContent1);
grpc_slice world = grpc_slice_from_copied_string(kContent2);
std::vector slices;
slices.push_back(Slice(hello, Slice::STEAL_REF));
slices.push_back(Slice(world, Slice::STEAL_REF));
ByteBuffer buffer(&slices[0], 2);
slices.clear();
(void)buffer.Dump(&slices);
EXPECT_TRUE(SliceEqual(slices[0], hello));
EXPECT_TRUE(SliceEqual(slices[1], world));
}
There was a problem hiding this comment.
Yeah, this is fine. I think if this was Envoy code we would want a test, but it's not worth the effort to deal with this in external deps that aren't written with mocking in mind.
| auto byte_buffer = GoogleGrpcUtils::makeByteBuffer(std::move(buffer)); | ||
| std::vector<grpc::Slice> slices; | ||
| byte_buffer.Dump(&slices); | ||
| RELEASE_ASSERT(byte_buffer.Dump(&slices).ok(), ""); |
There was a problem hiding this comment.
When can Dump fail? We should only use RELEASE_ASSERT in situations where it's effectively OOM and some unrecoverable situation exists. Otherwise, there should be error handling.
There was a problem hiding this comment.
See discussion in #6917.
Note: RELEASE_ASSERT is used only in tests, and failure is handled properly in the real code.
There was a problem hiding this comment.
This is fine in the tests then. I would still like to see the Dump condition mocked and tested if gRPC has mocks that can support this.
There was a problem hiding this comment.
This is a test, so it is a RELEASE__ASSERT. It should never fail. For the production code I am handling the error.
There was a problem hiding this comment.
See above regarding testing Dump().
Signed-off-by: John Plevyak <jplevyak@gmail.com>
For an explanation of how to fill out the fields, please see the relevant section
in PULL_REQUESTS.md
Description: Add a raw (Buffer::Instance) gRPC interface. The existing interface is layered on top
of a new raw interface which takes the service and method names as absl::string_view and which
passes the data to be sent and data received as Buffer::Instance(s). This is similar to the way
the existing typed interface is layered on the untyped interface. This enables extensions and
plugins to use gRPC without the gRPC service protobufs being compiled into envoy. This can also
support general gRPC proxies.
Risk Level: Medium
Testing: all existing tests pass.
Docs Changes: N/A (no externally visible change)
Release Notes: N/A
[Optional Fixes #Issue]
[Optional Deprecated:]