Skip to content

feat(triple): support generic call for Triple protocol#3154

Merged
AlexStocks merged 1 commit intoapache:developfrom
Tsukikage7:feat/generic-call
Jan 15, 2026
Merged

feat(triple): support generic call for Triple protocol#3154
AlexStocks merged 1 commit intoapache:developfrom
Tsukikage7:feat/generic-call

Conversation

@Tsukikage7
Copy link
Contributor

@Tsukikage7 Tsukikage7 commented Jan 6, 2026

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:

┌─────────────────────────────────────────────────────────────┐
│                    Wire Format                              │
├─────────────────────────────────────────────────────────────┤
│  Content-Type: application/proto                            │
│                                                             │
│  Request:  TripleRequestWrapper (protobuf)                  │
│            ├── serializeType: "hessian2"                    │
│            ├── args: [hessian2(arg1), hessian2(arg2), ...]  │
│            └── argTypes: ["java.lang.String", ...]          │
│                                                             │
│  Response: TripleResponseWrapper (protobuf)                 │
│            ├── serializeType: "hessian2"                    │
│            ├── data: hessian2(result)                       │
│            └── type: "org.apache.dubbo.samples.User"        │
└─────────────────────────────────────────────────────────────┘

This is a two-layer serialization: protobuf wrapper on the outside, hessian2 data on the
inside.

Implementation Details

1. New WrapperCodec Interface (codec.go)

type WrapperCodec interface {
    Codec
    WireCodecName() string  // Returns "proto" for Content-Type
}

2. New protoWrapperCodec (codec.go)

Client-side codec that wraps request arguments in TripleRequestWrapper and unwraps response
from TripleResponseWrapper.

3. Enhanced protoBinaryCodec (codec.go)

Server-side enhancement to handle incoming wrapped requests.

4. Generic Filter Enhancement (filter/generic/filter.go)

Added parameterRawValues support for Triple protocol in both isCallingToGenericService
and isMakingAGenericCall branches.

5. Server-side Generic Call Handler (protocol/triple/server.go)

Auto-registers $invoke method for Triple protocol services via buildGenericMethodInfo().

Testing

  • Unit Tests: 631 lines of comprehensive tests covering protoWrapperCodec,
    protoBinaryCodec, various data types, and edge cases.
  • Integration Tests: All scenarios passed (Go↔Java, Go↔Go via Triple protocol).

Compatibility

  • Backward Compatible: Existing IDL-based Triple calls are not affected
  • Cross-Language: Fully compatible with Java Dubbo 3.x Triple protocol
  • Dubbo Protocol: Existing Dubbo protocol generic call still works as before

Checklist

  • I confirm the target branch is main
  • Code has passed local testing
  • I have added tests that prove my fix is effective or that my feature works

Copy link
Contributor

Copilot AI left a 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 WrapperCodec interface and protoWrapperCodec implementation for handling the two-layer serialization format
  • Enhanced protoBinaryCodec to 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.

Copy link
Contributor

Copilot AI left a 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.

@Tsukikage7 Tsukikage7 force-pushed the feat/generic-call branch 5 times, most recently from 994396b to b50ad31 Compare January 6, 2026 06:17
@codecov-commenter
Copy link

codecov-commenter commented Jan 6, 2026

Codecov Report

❌ Patch coverage is 49.10714% with 114 lines in your changes missing coverage. Please review.
✅ Project coverage is 48.07%. Comparing base (2373adf) to head (27b78d1).

Files with missing lines Patch % Lines
server/server.go 22.44% 33 Missing and 5 partials ⚠️
protocol/triple/server.go 57.40% 22 Missing and 1 partial ⚠️
protocol/triple/triple_protocol/codec.go 57.40% 18 Missing and 5 partials ⚠️
client/client.go 0.00% 11 Missing ⚠️
protocol/triple/client.go 41.66% 5 Missing and 2 partials ⚠️
filter/generic/filter.go 79.31% 2 Missing and 4 partials ⚠️
client/options.go 0.00% 3 Missing ⚠️
protocol/triple/triple.go 70.00% 3 Missing ⚠️
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.
📢 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.

@Tsukikage7 Tsukikage7 changed the base branch from main to develop January 6, 2026 07:55
@AlexStocks AlexStocks added the 3.3.2 version 3.3.2 label Jan 8, 2026
Copy link
Member

@No-SilverBullet No-SilverBullet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :)

@Tsukikage7
Copy link
Contributor Author

@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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering is this todo solved?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建个issue,记下这个 todo 吧

Tsukikage7 added a commit to Tsukikage7/dubbo-go-samples that referenced this pull request Jan 15, 2026
…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]>
@Tsukikage7 Tsukikage7 force-pushed the feat/generic-call branch 2 times, most recently from 82eeed8 to ef9a9a5 Compare January 15, 2026 04:18
Tsukikage7 added a commit to Tsukikage7/dubbo-go-samples that referenced this pull request Jan 15, 2026
…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]>
@Tsukikage7 Tsukikage7 force-pushed the feat/generic-call branch 3 times, most recently from 3c168c6 to ab60000 Compare January 15, 2026 04:31
Tsukikage7 added a commit to Tsukikage7/dubbo-go-samples that referenced this pull request Jan 15, 2026
…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]>
@AlexStocks
Copy link
Contributor

当前代码我留了一个 comment,请改进。另外,请给其中一些函数添加 unit test。

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
@sonarqubecloud
Copy link

@AlexStocks AlexStocks merged commit ee68159 into apache:develop Jan 15, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants