feat: add variadic RPC warnings and checks#3294
feat: add variadic RPC warnings and checks#3294mochengqian wants to merge 2 commits intoapache:developfrom
Conversation
|
I need a guidance : I haven't found a suitable way to add migration guidelines for the new cross-language service. The specific content of the migration guidelines is as follows: 1.Recommend []T instead of ...T for interface-based definitions. |
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #3294 +/- ##
===========================================
+ Coverage 46.76% 50.21% +3.45%
===========================================
Files 295 486 +191
Lines 17172 36435 +19263
===========================================
+ Hits 8031 18297 +10266
- Misses 8287 16682 +8395
- Partials 854 1456 +602 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|



Description
Fixes #3286(issue)
Background
Issue #3259 exposed a real interoperability problem around variadic Go RPC methods such as
args ...stringwhen they are used from generic invocation or cross-language scenarios.PR #3284 already addressed the short-term runtime compatibility path. This PR focuses on the long-term guidance side, so we can keep existing services compatible while discouraging new risky contracts from being introduced.
The goal of this PR is not to hinder existing users or further tighten runtime behavior, but to identify risks as early as possible and provide a clearer migration path for new cross-language services.
What this PR does
This PR adds non-breaking guidance in three places:
variadicrpcchecktool to detect exported variadic RPC contracts in CI or local development.Runtime guidance
A reusable helper was added in
common/rpc_service.goto detect variadic RPC methods based on the existingsuiteMethodexport rules. This keeps the detection logic aligned with what Dubbo-go actually treats as exported RPC methods.During service registration,
server/server.gonow emits a warning if the service exposes variadic RPC methods. The warning is non-blocking and explicitly says:...T[]T, request structs, or Triple + Protobuf IDL are preferred for new contractsThis warning path is shared by
Register(...),RegisterService(...), and generatedRegister<Service>Handler(...)flows through the same registration path.Tooling guidance
This PR adds
tools/variadicrpccheck, a warning-only scanner built ongo/packages+ AST/type information.It scans exported service interfaces and exported service implementations for variadic RPC-style signatures, and prints file/line warnings with migration guidance.
A few guardrails are included to keep the first version practical:
*_test.go*.pb.go*.triple.goopts ...OptionThe tool is wired into
make rpc-contract-checkand added to GitHub Actions after lint. It is guidance-only and always exits with0, so it will not block CI.Checklist
develop