-
Notifications
You must be signed in to change notification settings - Fork 990
feat(triple): support generic call for Triple protocol #3154
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
base: develop
Are you sure you want to change the base?
Conversation
a20282b to
1e747e9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
64d3d19 to
994396b
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
994396b to
b50ad31
Compare
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #3154 +/- ##
==========================================
+ Coverage 47.80% 48.00% +0.19%
==========================================
Files 460 460
Lines 33011 33187 +176
==========================================
+ Hits 15782 15930 +148
- Misses 15963 15967 +4
- Partials 1266 1290 +24 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
No-SilverBullet
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM :)



What this PR does
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.
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)This interface allows a codec to use different names for:
Name()returns "hessian2"WireCodecName()returns "proto"2. New
protoWrapperCodec(codec.go)Client-side codec that:
TripleRequestWrapperTripleResponseWrapper3. Enhanced
protoBinaryCodec(codec.go)Server-side enhancement to handle incoming wrapped requests:
TripleRequestWrapper/TripleResponseWrapper4. Generic Filter Enhancement (
filter/generic/filter.go)Added
parameterRawValuessupport for Triple protocol in both branches:isCallingToGenericService: When user calls normal method (e.g.,GetUser), filter transforms to$invokeformatisMakingAGenericCall: When user directly calls$invoke, filter sets upparameterRawValuesfor Triple5. Server-side Generic Call Handler (
protocol/triple/server.go)Auto-registers
$invokemethod for Triple protocol services viabuildGenericMethodInfo():Call Flow
Request (Go Client → Java Server)
genericService.Invoke(ctx, "GetUser", types, args)$invoke$invoke("GetUser", ["java.lang.String"], ["user123"])[]bytefor each argprotobuf{serializeType, args[], argTypes[]}Content-Type: application/protoResponse (Java Server → Go Client)
TripleResponseWrapper{data, type}Content-Type: application/protohessian2 bytesUser objectmap[string]interface{}Files Changed
protocol/triple/triple_protocol/codec.goWrapperCodecinterface,protoWrapperCodec, enhanceprotoBinaryCodecprotocol/triple/triple_protocol/codec_wrapper_test.gofilter/generic/filter.goparameterRawValuesandCallTypefor Triple protocol in both branchesclient/client.goclient/options.goWithGeneric()optionprotocol/triple/client.goprotocol/triple/server.go$invokemethod registration, handle generic call on server sideprotocol/triple/triple.gocommon/constant/key.goprotocol/triple/triple_protocol/protocol_grpc.gogetWireCodecName()for Content-Typeprotocol/triple/triple_protocol/protocol_triple.gogetWireCodecName()for Content-TypeTesting
Unit Tests: 631 lines of comprehensive tests covering:
protoWrapperCodecmarshal/unmarshalprotoBinaryCodecwrapper handlingIntegration Tests:
Usage Example
Compatibility
Signed-off-by: TsukiKage chongyanx@163.com