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

feat(gRPC): add monitor goroutine for each gRPC client stream #1650

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

DMwangnima
Copy link
Contributor

What type of PR is this?

feat

Check the PR title.

  • This PR title match the format: <type>(optional scope): <description>
  • The description of this PR title is user-oriented and clear enough for others to understand.
  • Attach the PR updating the user documentation if the current PR requires user awareness at the usage level. User docs repo

(Optional) Translate the PR title into Chinese.

feat(gRPC): 为每个 gRPC 的 client stream 添加一个监测 goroutine

(Optional) More detailed description for this PR(en: English/zh: Chinese).

en:
Currently either the user calls thecancelfunction, or the parent stream is cancelled:

  • handler exits
  • Parent stream received RstStream Frame
  • ...
    Users have to callstream.Recv()to detect if the ctx has been cancelled and close the stream, which is not intuitive.
    Therefore, each stream is equipped with a monitoring goroutine that detects if the ctx is cancelled and automatically triggers the logic to close the stream.
    Unary must call stream.Recv(), so there is no need to create a monitoring goroutine.

zh(optional):
当前无论是用户主动调用cancel函数,还是父 stream 被 cancel:

  • handler 退出
  • 父 stream 收到 RstStream Frame
  • ...
    都需要用户主动调用stream.Recv()来检测 ctx 是否被 cancel,从而关闭流,这样很不符合直觉。
    因此为每个 stream 配备一个监测 goroutine 用来检测 ctx 是否被 cancel,从而自动地触发关闭流的逻辑。
    unary 必定会调用stream.Recv,因此不需要配备。

(Optional) Which issue(s) this PR fixes:

(optional) The PR that updates user documentation:

@DMwangnima DMwangnima requested review from a team as code owners December 23, 2024 09:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant