feat(generic): add generic call sample for both Dubbo and Triple protocols#1016
feat(generic): add generic call sample for both Dubbo and Triple protocols#1016Tsukikage7 wants to merge 2 commits intoapache:mainfrom
Conversation
9babfa4 to
da7f82d
Compare
|
9fe8d23 to
3e4db86
Compare
There was a problem hiding this comment.
Pull request overview
This PR refactors the generic call sample to demonstrate both Dubbo and Triple protocol generic calls between Go and Java. The refactoring includes dual protocol support, project structure simplification, and a comprehensive test suite with 19 test cases.
Changes:
- Added dual protocol support (Dubbo on port 20000 and Triple on port 50052) with separate service groups
- Refactored project structure by removing redundant nested directories (java-server/java-server → java-server)
- Added comprehensive test coverage with 19 test cases and 2 benchmarks for generic calls
- Changed QueryUsers signature from List to User[] for consistency
Reviewed changes
Copilot reviewed 30 out of 38 changed files in this pull request and generated 16 comments.
Show a summary per file
| File | Description |
|---|---|
| go.mod | Added local replace directive for dubbo-go dependency (temporary) |
| generic/java-server/src/main/java/org/apache/dubbo/samples/ApiProvider.java | New dual protocol server implementation |
| generic/java-server/src/main/java/org/apache/dubbo/samples/User.java | Added User POJO class |
| generic/java-server/src/main/java/org/apache/dubbo/samples/Gender.java | Added Gender enum |
| generic/java-server/src/main/java/org/apache/dubbo/samples/UserProvider.java | Changed QueryUsers from List to array |
| generic/java-server/src/main/java/org/apache/dubbo/samples/UserProviderImpl.java | Updated QueryUsers implementation |
| generic/java-client/src/main/java/org/apache/dubbo/samples/ApiTripleConsumer.java | New Triple protocol consumer |
| generic/java-client/pom.xml | New client pom configuration |
| generic/go-server/cmd/server.go | Simplified server implementation |
| generic/go-server/pkg/user_provider.go | Added Invoke method for generic calls |
| generic/go-client/cmd/client.go | Refactored to test both protocols |
| generic/go-client/cmd/client_test.go | Added comprehensive test suite |
| generic/README.md | Updated documentation |
| generic/README_zh.md | Updated Chinese documentation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
go.mod
Outdated
| ) | ||
|
|
||
| replace ( | ||
| dubbo.apache.org/dubbo-go/v3 => ../dubbo-go |
There was a problem hiding this comment.
The local replace directive points to a relative path '../dubbo-go' which is a temporary development dependency. This should be removed before merging to production. The PR description mentions this depends on apache/dubbo-go#3154, so this replace directive should only be present during development/testing and removed once that PR is merged.
generic/README_zh.md
Outdated
| 启动 ZooKeeper: | ||
|
|
||
| - Docker 和 Docker Compose 用于运行 ZooKeeper 注册中心 | ||
| - Go 1.23+ 用于 Dubbo-Go 示例 | ||
| - Java 8+ 和 Maven 用于 Dubbo Java 示例 | ||
| ```bash | ||
| docker run -d --name zookeeper -p 2181:2181 zookeeper:3.8 | ||
| ``` |
There was a problem hiding this comment.
The Chinese README also includes ZooKeeper setup instructions in the Prerequisites section, which is inconsistent with the direct connection approach described in the PR. This section should be updated to match the removal of ZooKeeper dependency.
|
Please fix the ci failure and review the copilot's comment. |
|
这个ci fail只能等dubbogo发新tag才能解决 |
go.mod
Outdated
| ) | ||
|
|
||
| replace ( | ||
| dubbo.apache.org/dubbo-go/v3 => ../dubbo-go |
There was a problem hiding this comment.
这个我等一下改一下,我把copliot提的那些问题修复一下吧
5c4a941 to
5d068dd
Compare
|
ci失败处理下吧 |
5d068dd to
cf340d7
Compare
1 fix(deps): update dubbo-go to latest commit with NewGenericService API 2 3 - Replace local path with github commit v3.0.0-20260210015753-35ea886421f9 4 - This commit includes the NewGenericService API (apache/dubbo-go#3154) 5 - Fixes CI compilation errors for generic call sample 6 7 Resolves: apache#1016 (CI failure)
28d3472 to
27ddd80
Compare
go.mod
Outdated
| ) | ||
|
|
||
| replace ( | ||
| dubbo.apache.org/dubbo-go/v3 => github.com/apache/dubbo-go/v3 v3.0.0-20260210015753-35ea886421f9 |
|
现在这个sample加到集成测试里面了吗 |
generic/go-client/cmd/client_test.go
Outdated
| &pkg.User{ID: "003", Name: "User3", Age: 30, Time: time.Now()}, | ||
| } | ||
|
|
||
| result, err := svc.Invoke(context.Background(), "QueryUsers", []string{"java.util.List"}, []hessian.Object{users}) |
generic/java-server/pom.xml
Outdated
There was a problem hiding this comment.
这里改成 3.8.4 好像才能跑通,我这是这样的,希望别人也来测下。
6a8f438 to
f3bceec
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. | Protocol | Port | Group | Description | |----------|-------|----------|----------------------------------| | Dubbo | 20000 | `dubbo` | Traditional Dubbo binary protocol| | Triple | 50052 | `triple` | HTTP/2 based Triple protocol | - Removed ZooKeeper dependency in favor of direct URL connection - Simplifies local testing and CI/CD pipelines - No external dependencies required to run the sample - Removed redundant nested directories (java-server/java-server → java-server) - Added run.sh scripts for easy execution Added client_test.go with test cases covering: - Dubbo Protocol Tests (6 cases) - Triple Protocol Tests (13 cases) - Benchmarks for both protocols - 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 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 <chongyanx@163.com>
f3bceec to
1eaf803
Compare
|
pls fix confilct |
What this PR does
This PR refactors and enhances the generic call sample to demonstrate both Dubbo protocol and Triple protocol generic calls between Go and Java.
Background
The existing generic sample only demonstrated Dubbo protocol generic call. With the new Triple protocol generic call support in dubbo-go (see apache/dubbo-go#3154), this sample needs to be updated to showcase both protocols.
Changes Overview
1. Dual Protocol Support
The sample now demonstrates generic call on both protocols:
dubbotriple2. Java Server Enhancement
Before: Single protocol, ZooKeeper dependency
After: Dual protocol, direct connection mode
3. Go Client Enhancement
Before: Only Dubbo protocol test
After: Tests both Dubbo and Triple protocols using new
GenericServiceAPI4. Comprehensive Test Suite
Added
client_test.gowith 19 test cases:Dubbo Protocol Tests (6 cases):
TestDubboGenericCall_StringArgTestDubboGenericCall_MultipleArgsTestDubboGenericCall_IntArgTestDubboGenericCall_NoArgsTestDubboGenericCall_ArrayArgTestDubboGenericCall_POJOArgTriple Protocol Tests (13 cases):
TestTripleGenericCall_StringArgTestTripleGenericCall_MultipleArgsTestTripleGenericCall_IntArgTestTripleGenericCall_NoArgsTestTripleGenericCall_ArrayArgTestTripleGenericCall_POJOArgTestTripleGenericCall_POJOArrayArgTestTripleGenericCall_MapResultTestTripleGenericCall_ListResultTestTripleGenericCall_EmptyArrayArgTestTripleGenericCall_NonExistentMethodTestTripleGenericCall_WithTimeoutTestTripleGenericCall_WithCancelledContextBenchmarks:
BenchmarkDubboGenericCallBenchmarkTripleGenericCall5. Project Structure Simplification
Before (nested directories):
After (flat structure):
6. Removed ZooKeeper Dependency
Files Changed
generic/java-server/src/.../ApiProvider.javageneric/java-client/src/.../ApiTripleConsumer.javageneric/go-client/cmd/client.gogeneric/go-client/cmd/client_test.gogeneric/go-server/cmd/server.gogeneric/go-server/pkg/user_provider.gogeneric/java-server/run.shgeneric/java-client/run.shgeneric/README.mdgeneric/README_zh.mdgeneric/java-*/java-*/generic/build/test.shHow to Test
1. Start Java Server
cd generic/java-server ./run.sh2. Run Go Client Tests
3. Or Run Go Client Manually
cd generic/go-client/cmd go run client.goTest Results
Related PRs
Signed-off-by: TsukiKage chongyanx@163.com