Skip to content

Comments

grpc: implement BufferedAsyncClient for bidirectional gRPC stream#18129

Merged
lizan merged 15 commits intoenvoyproxy:mainfrom
Shikugawa:buffered-grpc-client
Nov 10, 2021
Merged

grpc: implement BufferedAsyncClient for bidirectional gRPC stream#18129
lizan merged 15 commits intoenvoyproxy:mainfrom
Shikugawa:buffered-grpc-client

Conversation

@Shikugawa
Copy link
Member

@Shikugawa Shikugawa commented Sep 15, 2021

Signed-off-by: Shikugawa [email protected]

Commit Message: grpc: implement BufferedAsyncClient for bidirectional gRPC stream
Additional Description: This function is a component for buffering and tracking the state of messages sent in the gRPC bidirectional stream. This component makes it possible to monitor and control the transmission status of highly granular messages from the Envoy side, and is identical to the one implemented in #17486.
Risk Level: Low
Testing: Unit
Docs Changes:
Release Notes:
Platform Specific Features:
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Deprecated:]
[Optional API Considerations:]

cc @snowp @lizan

@Shikugawa
Copy link
Member Author

/assign-from @envoyproxy/envoy-maintainers

@repokitteh-read-only
Copy link

@envoyproxy/envoy-maintainers assignee is @dio

🐱

Caused by: a #18129 (comment) was created by @Shikugawa.

see: more, trace.

Signed-off-by: Shikugawa <[email protected]>
Copy link
Member

@mathetake mathetake left a comment

Choose a reason for hiding this comment

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

Overall I would like to see the doc comment on the class.

@Shikugawa
Copy link
Member Author

@lizan Fixed not to expose publishId(). Could you take a look?

@mattklein123
Copy link
Member

ping @lizan PTAL

@davinci26
Copy link
Member

/retest

@repokitteh-read-only
Copy link

Retrying Azure Pipelines:
Retried failed jobs in: envoy-presubmit

🐱

Caused by: a #18129 (comment) was created by @davinci26.

see: more, trace.

@Shikugawa
Copy link
Member Author

/retest

@repokitteh-read-only
Copy link

Retrying Azure Pipelines:
Check envoy-presubmit didn't fail.

🐱

Caused by: a #18129 (comment) was created by @Shikugawa.

see: more, trace.

@Shikugawa
Copy link
Member Author

/retest

@repokitteh-read-only
Copy link

Retrying Azure Pipelines:
Check envoy-presubmit didn't fail.

🐱

Caused by: a #18129 (comment) was created by @Shikugawa.

see: more, trace.

Signed-off-by: Shikugawa <[email protected]>
@lizan lizan added the waiting label Oct 15, 2021
@Shikugawa Shikugawa closed this Oct 15, 2021
@repokitteh-read-only
Copy link

Retrying Azure Pipelines:
Retried failed jobs in: envoy-presubmit

🐱

Caused by: a #18129 (comment) was created by @Shikugawa.

see: more, trace.

@Shikugawa Shikugawa reopened this Oct 15, 2021
@Shikugawa
Copy link
Member Author

/retest

@repokitteh-read-only
Copy link

Retrying Azure Pipelines:
Retried failed jobs in: envoy-presubmit

🐱

Caused by: a #18129 (comment) was created by @Shikugawa.

see: more, trace.

Signed-off-by: Shikugawa <[email protected]>
@Shikugawa
Copy link
Member Author

@lizan friendly ping

lizan
lizan previously approved these changes Nov 2, 2021
@lizan lizan removed their assignment Nov 2, 2021
@lizan
Copy link
Member

lizan commented Nov 2, 2021

/assign-from @envoyproxy/envoy-maintainers

for non-tetrands review

@repokitteh-read-only
Copy link

@envoyproxy/envoy-maintainers assignee is @zuercher

🐱

Caused by: a #18129 (comment) was created by @lizan.

see: more, trace.

Copy link
Member

@zuercher zuercher left a comment

Choose a reason for hiding this comment

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

Just some questions about the API for the template. Let me know what you think.

}

auto id = publishId();
message_buffer_[id] = std::make_pair(BufferState::Buffered, message);
Copy link
Member

Choose a reason for hiding this comment

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

In #17486 this id is set on the RequestType (CriticalAccessLogsMessage). In conjunction with the previous comment, maybe we should return absl::optional<uint64_t> with the id if buffered or null_opt if the buffer's full? The caller can then add the id to the message (although that kind of change via the message reference feels a little weird). Another possibility is to require that the id is passed obtained via publishId, used to call set_id on the message, and then passed to bufferMessage as a separate parameter.

Copy link
Member Author

Choose a reason for hiding this comment

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

I missed it. I agree with to return absl::optional<uint64_t> them the caller set it to the message.

Signed-off-by: Shikugawa <[email protected]>
Signed-off-by: Shikugawa <[email protected]>
Copy link
Member

@zuercher zuercher left a comment

Choose a reason for hiding this comment

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

Thanks. I had some final comments, but otherwise looks good.

auto& message = it.second.second;

if (state == BufferState::PendingFlush) {
continue;
Copy link
Member

Choose a reason for hiding this comment

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

I think we should add a test that covers this case, since it prevents double sending. I noticed it's not hit in the coverage report

Copy link
Member Author

Choose a reason for hiding this comment

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

added

}
}

absl::optional<uint64_t> bufferMessage(RequestType& message) {
Copy link
Member

Choose a reason for hiding this comment

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

nit: Consider adding a comment that indicates that null_opt means buffer full.

Copy link
Member Author

Choose a reason for hiding this comment

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

added

Signed-off-by: Shikugawa <[email protected]>
Copy link
Member

@zuercher zuercher left a comment

Choose a reason for hiding this comment

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

Thanks!

@Shikugawa
Copy link
Member Author

@lizan Ready to merge

@lizan lizan merged commit 6df4b00 into envoyproxy:main Nov 10, 2021
mpuncel added a commit to mpuncel/envoy that referenced this pull request Nov 10, 2021
* main: (71 commits)
  bazel: fix macOS build (envoyproxy#18920)
  http: switching from 100 to 1xx (envoyproxy#18904)
  grpc: implement BufferedAsyncClient for bidirectional gRPC stream (envoyproxy#18129)
  bazel: add repository arg to benchmark_test (envoyproxy#18795)
  rocketmq_proxy: Improvement for map find (envoyproxy#18909)
  tls: unit test: spiffe signed by intermediate cert (envoyproxy#18914)
  Test for FilterConfigPerRoute dtor called on worker thread. (envoyproxy#18927)
  deps: Bump `com_google_protobuf` -> 3.19.1 (envoyproxy#18930)
  deps: Bump `com_googlesource_code_re2` -> 2021-11-01 (envoyproxy#18933)
  cvescan: Move cvescan data to yaml (envoyproxy#18947)
  remove unnecessary file level not unimplemented hide annotation (envoyproxy#18924)
  test: moving echo test (envoyproxy#18938)
  test: fixing a test flake (envoyproxy#18899)
  deps: Revert pyparsing bump (envoyproxy#18946)
  deps: Bump `build_bazel_rules_apple` -> 0.32.0 (envoyproxy#18932)
  deps: Bump `com_github_bazelbuild_buildtools` -> 4.2.3 (envoyproxy#18931)
  build(deps): bump pycparser from 2.20 to 2.21 in /tools/dependency (envoyproxy#18936)
  quic: supporting connections with zero initial available streams (envoyproxy#18775)
  test: moving proxy proto (envoyproxy#18939)
  build(deps): bump pyparsing from 3.0.4 to 3.0.5 in /tools/dependency (envoyproxy#18937)
  ...

Signed-off-by: Michael Puncel <[email protected]>
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.

7 participants