Skip to content

Conversation

DMwangnima
Copy link
Contributor

@DMwangnima DMwangnima commented Dec 23, 2024

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): 为已经被 cancel 的 gRPC client stream 添加一个监测 closeStreamTask

(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, the closeStreamTask is introduced to periodically (currently 5s) detect streams that have been cancelled to avoid stream leakage.

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

  • handler 退出
  • 父 stream 收到 RstStream Frame
  • ...
    都需要用户主动调用stream.Recv()来检测 ctx 是否被 cancel,从而关闭流,这样很不符合直觉。
    因此引入 closeStreamTask 周期性地(当前为 5s)检测已经被 cancel 的 stream,避免 stream 泄漏。

(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
@DMwangnima DMwangnima force-pushed the feat/gRPC_monitor_goroutine branch from b9d7633 to fd805c4 Compare February 13, 2025 01:38
@DMwangnima DMwangnima changed the title feat(gRPC): add monitor goroutine for each gRPC client stream feat(gRPC): add monitor closeStreamTask for cancelled gRPC client stream Feb 13, 2025
@DMwangnima DMwangnima force-pushed the feat/gRPC_monitor_goroutine branch from fd805c4 to 61e0175 Compare February 13, 2025 01:46
@DMwangnima DMwangnima merged commit 885b05a into cloudwego:develop Feb 13, 2025
19 checks passed
@DMwangnima DMwangnima deleted the feat/gRPC_monitor_goroutine branch February 13, 2025 06:40
HeyJavaBean pushed a commit to HeyJavaBean/kitex that referenced this pull request Feb 21, 2025
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.

3 participants