Skip to content

refactor(streaming): extract shared client-side stream into internal/… - #1975

Open
junliurs wants to merge 1 commit into
cloudwego:mainfrom
junliurs:refactor/extract-common-client-stream
Open

refactor(streaming): extract shared client-side stream into internal/…#1975
junliurs wants to merge 1 commit into
cloudwego:mainfrom
junliurs:refactor/extract-common-client-stream

Conversation

@junliurs

Copy link
Copy Markdown
Contributor

…clientstream

The client-side gRPC stream logic (send/recv event tracing, DoFinish idempotency, BizStatusError surfacing, recv-timeout handling and the client-streaming end-of-stream semantics) was duplicated between the network client (client package) and the in-process LocalCaller (server package).

Extract this shared behavior into a new internal/clientstream package exposing a reusable CommonStream, and add internal/localstream providing the in-process stream pair used by LocalCaller. Both client.stream and LocalCaller now embed CommonStream and inject transport-specific behavior (connection release, recv timeout, trace-finish ownership) through Options, so the two callers no longer maintain divergent copies.

internal/clientstream must not import client/server/remotecli to avoid import cycles.

No behavior change; existing client and server tests pass.

What type of PR is this?

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.

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

en:
zh(optional):

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

(optional) The PR that updates user documentation:

@junliurs
junliurs requested review from a team as code owners July 10, 2026 07:47
@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 76.04651% with 103 lines in your changes missing coverage. Please review.
✅ Project coverage is 62.97%. Comparing base (d27f7db) to head (40139f9).
⚠️ Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
internal/localstream/localstream.go 66.66% 69 Missing and 2 partials ⚠️
server/local_caller.go 64.70% 11 Missing and 7 partials ⚠️
internal/clientstream/stream.go 91.80% 7 Missing and 3 partials ⚠️
internal/clientstream/grpc_stream.go 66.66% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1975      +/-   ##
==========================================
+ Coverage   62.84%   62.97%   +0.12%     
==========================================
  Files         394      398       +4     
  Lines       30267    30603     +336     
==========================================
+ Hits        19022    19272     +250     
- Misses       9948    10029      +81     
- Partials     1297     1302       +5     
Flag Coverage Δ
integration 51.32% <29.53%> (-0.53%) ⬇️
unit 53.72% <70.46%> (+0.30%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@junliurs
junliurs force-pushed the refactor/extract-common-client-stream branch from 2cc0f82 to 65ac6c6 Compare July 10, 2026 09:09
…clientstream

The client-side gRPC stream logic (send/recv event tracing, DoFinish
idempotency, BizStatusError surfacing, recv-timeout handling and the
client-streaming end-of-stream semantics) was duplicated between the
network client (client package) and the in-process LocalCaller
(server package).

Extract this shared behavior into a new internal/clientstream package
exposing a reusable CommonStream, and add internal/localstream providing
the in-process stream pair used by LocalCaller. Both client.stream and
LocalCaller now embed CommonStream and inject transport-specific behavior
(connection release, recv timeout, trace-finish ownership) through
Options, so the two callers no longer maintain divergent copies.

internal/clientstream must not import client/server/remotecli to avoid
import cycles.

No behavior change; existing client and server tests pass.
@junliurs
junliurs force-pushed the refactor/extract-common-client-stream branch from 65ac6c6 to 40139f9 Compare July 15, 2026 06:46
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