feat(triple): support generic call for Triple protocol#3154
feat(triple): support generic call for Triple protocol#3154AlexStocks merged 1 commit intoapache:developfrom
Conversation
a20282b to
1e747e9
Compare
There was a problem hiding this comment.
Pull request overview
This PR implements Triple protocol generic call support for dubbo-go, enabling Go clients to invoke Java Dubbo services without pre-generated stubs and vice versa. The implementation uses a two-layer serialization approach: protobuf wrapper on the outside (TripleRequestWrapper/TripleResponseWrapper) with hessian2-encoded data on the inside, matching Java Dubbo's wire format.
Key changes:
- Introduced
WrapperCodecinterface andprotoWrapperCodecimplementation for handling the two-layer serialization format - Enhanced
protoBinaryCodecto automatically detect and unwrap generic calls on the server side - Added reflection-based method invocation infrastructure to support dynamic service method calls
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| protocol/triple/triple_protocol/codec.go | Adds WrapperCodec interface, protoWrapperCodec for client-side wrapping, and enhances protoBinaryCodec for server-side unwrapping |
| protocol/triple/triple_protocol/codec_wrapper_test.go | Comprehensive unit tests (631 lines) covering wrapper codec functionality, type mapping, and edge cases |
| server/server.go | Adds reflection-based method invocation support and enhances service info with $invoke method registration |
| protocol/triple/server.go | Refactors generic method info building and adds reflection-based MethodFunc creation |
| protocol/triple/client.go | Routes generic calls to $invoke method and registers it for non-IDL mode |
| filter/generic/filter.go | Adds parameterRawValues support for Triple protocol generic calls |
| protocol/triple/triple.go | Routes to NewTripleInvoker when generic call is detected |
| protocol/triple/triple_protocol/protocol_grpc.go | Uses getWireCodecName for correct Content-Type header |
| protocol/triple/triple_protocol/protocol_triple.go | Uses getWireCodecName for correct Content-Type header |
| common/constant/key.go | Adds protobuf and protobuf-json generic serialization constants |
| client/options.go | Adds WithGenericType option for specifying generic serialization type |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
994396b to
b50ad31
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #3154 +/- ##
===========================================
+ Coverage 47.81% 48.07% +0.26%
===========================================
Files 460 460
Lines 32999 33172 +173
===========================================
+ Hits 15779 15948 +169
+ Misses 15952 15935 -17
- Partials 1268 1289 +21 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@marsevilspirit @Alanxtl Need Review pls. |
|
|
||
| // Add a method with a name of a different first-letter case | ||
| // to achieve interoperability with java | ||
| // TODO: The method name case sensitivity in Dubbo-java should be addressed. |
There was a problem hiding this comment.
I'm wondering is this todo solved?
There was a problem hiding this comment.
Partially. The enhanceServiceInfo function now registers both GetUser and getUser style methods, so Go and Java can find each other. But the real fix should be on dubbo-java side to handle case properly. Kept the TODO as a reminder - maybe we can push for a fix upstream later.
…ocols This PR refactors and enhances the generic call sample to demonstrate both Dubbo protocol and Triple protocol generic calls between Go and Java. ## Changes Overview ### 1. Dual Protocol Support | Protocol | Port | Group | Description | |----------|-------|----------|----------------------------------| | Dubbo | 20000 | `dubbo` | Traditional Dubbo binary protocol| | Triple | 50052 | `triple` | HTTP/2 based Triple protocol | ### 2. Direct Connection Mode - Removed ZooKeeper dependency in favor of direct URL connection - Simplifies local testing and CI/CD pipelines - No external dependencies required to run the sample ### 3. Project Structure Simplification - Removed redundant nested directories (java-server/java-server → java-server) - Added run.sh scripts for easy execution ### 4. Comprehensive Test Suite Added client_test.go with test cases covering: - Dubbo Protocol Tests (6 cases) - Triple Protocol Tests (13 cases) - Benchmarks for both protocols ### 5. Code Improvements - Go server uses direct connection mode (no registry) - user_provider.go Invoke method returns proper error for unknown methods - Fixed QueryUsers parameter type to match Java array signature ## Dependencies This PR depends on apache/dubbo-go#3154 which adds `NewGenericService` API. CI will pass after that PR is merged to main branch. Signed-off-by: TsukiKage <[email protected]> Co-Authored-By: Claude Opus 4.5 <[email protected]>
82eeed8 to
ef9a9a5
Compare
…ocols This PR refactors and enhances the generic call sample to demonstrate both Dubbo protocol and Triple protocol generic calls between Go and Java. ## Changes Overview ### 1. Dual Protocol Support | Protocol | Port | Group | Description | |----------|-------|----------|----------------------------------| | Dubbo | 20000 | `dubbo` | Traditional Dubbo binary protocol| | Triple | 50052 | `triple` | HTTP/2 based Triple protocol | ### 2. Direct Connection Mode - Removed ZooKeeper dependency in favor of direct URL connection - Simplifies local testing and CI/CD pipelines - No external dependencies required to run the sample ### 3. Project Structure Simplification - Removed redundant nested directories (java-server/java-server → java-server) - Added run.sh scripts for easy execution ### 4. Comprehensive Test Suite Added client_test.go with test cases covering: - Dubbo Protocol Tests (6 cases) - Triple Protocol Tests (13 cases) - Benchmarks for both protocols ### 5. Code Improvements - Go server uses direct connection mode (no registry) - user_provider.go Invoke method returns proper error for unknown methods - Fixed QueryUsers parameter type to match Java array signature ## Dependencies This PR depends on apache/dubbo-go#3154 which adds `NewGenericService` API. CI will pass after that PR is merged to main branch. Signed-off-by: TsukiKage <[email protected]>
3c168c6 to
ab60000
Compare
…ocols This PR refactors and enhances the generic call sample to demonstrate both Dubbo protocol and Triple protocol generic calls between Go and Java. ## Changes Overview ### 1. Dual Protocol Support | Protocol | Port | Group | Description | |----------|-------|----------|----------------------------------| | Dubbo | 20000 | `dubbo` | Traditional Dubbo binary protocol| | Triple | 50052 | `triple` | HTTP/2 based Triple protocol | ### 2. Direct Connection Mode - Removed ZooKeeper dependency in favor of direct URL connection - Simplifies local testing and CI/CD pipelines - No external dependencies required to run the sample ### 3. Project Structure Simplification - Removed redundant nested directories (java-server/java-server → java-server) - Added run.sh scripts for easy execution ### 4. Comprehensive Test Suite Added client_test.go with test cases covering: - Dubbo Protocol Tests (6 cases) - Triple Protocol Tests (13 cases) - Benchmarks for both protocols ### 5. Code Improvements - Go server uses direct connection mode (no registry) - user_provider.go Invoke method returns proper error for unknown methods - Fixed QueryUsers parameter type to match Java array signature ## Dependencies This PR depends on apache/dubbo-go#3154 which adds `NewGenericService` API. CI will pass after that PR is merged to main branch. Signed-off-by: TsukiKage <[email protected]>
|
当前代码我留了一个 comment,请改进。另外,请给其中一些函数添加 unit test。 |
ab60000 to
c002627
Compare
Add generic call support for Triple protocol in non-IDL mode, enabling Go clients to invoke Java services without pre-generated stubs. Changes: - Add protoWrapperCodec for wrapping hessian2 data in protobuf format - Support protoBinaryCodec unmarshaling wrapped hessian2 responses - Set CallType and parameterRawValues in generic filter for Triple - Add NewGenericService API in client package
c002627 to
27b78d1
Compare
|



Description
This PR implements Triple protocol generic call support for dubbo-go, enabling Go clients
to invoke Java Dubbo services without pre-generated stubs and vice versa.
For detailed design documentation, please refer to: Dubbo-go Triple Generic
Call
Related PR: apache/dubbo-go-samples#1016 provides usage examples for Triple protocol
generic call.
Background
Generic call (泛化调用) is a core feature in Dubbo ecosystem that allows service invocation
without IDL/interface definitions. While dubbo-go already supports generic call for the Dubbo
protocol, Triple protocol generic call was missing, making it impossible for Go and Java
services to interoperate via Triple protocol in non-IDL mode.
Design Overview
The key challenge is that Java Dubbo Triple protocol uses a specific wire format for non-IDL
mode:
This is a two-layer serialization: protobuf wrapper on the outside, hessian2 data on the
inside.
Implementation Details
1. New
WrapperCodecInterface (codec.go)2. New
protoWrapperCodec(codec.go)Client-side codec that wraps request arguments in
TripleRequestWrapperand unwraps responsefrom
TripleResponseWrapper.3. Enhanced
protoBinaryCodec(codec.go)Server-side enhancement to handle incoming wrapped requests.
4. Generic Filter Enhancement (
filter/generic/filter.go)Added
parameterRawValuessupport for Triple protocol in bothisCallingToGenericServiceand
isMakingAGenericCallbranches.5. Server-side Generic Call Handler (
protocol/triple/server.go)Auto-registers
$invokemethod for Triple protocol services viabuildGenericMethodInfo().Testing
protoWrapperCodec,protoBinaryCodec, various data types, and edge cases.Compatibility
Checklist
main