Skip to content

Commit 28d3472

Browse files
committed
STDIN
1 feat(generic): add generic call sample for both Dubbo and Triple protocols 2 3 This PR refactors and enhances the generic call sample to demonstrate 4 both Dubbo protocol and Triple protocol generic calls between Go and Java. 5 6 ## Changes Overview 7 8 ### 1. Dual Protocol Support 9 | Protocol | Port | Group | Description | 10 |----------|-------|----------|----------------------------------| 11 | Dubbo | 20000 | `dubbo` | Traditional Dubbo binary protocol| 12 | Triple | 50052 | `triple` | HTTP/2 based Triple protocol | 13 14 ### 2. Direct Connection Mode 15 - Removed ZooKeeper dependency in favor of direct URL connection 16 - Simplifies local testing and CI/CD pipelines 17 - No external dependencies required to run the sample 18 19 ### 3. Project Structure Simplification 20 - Removed redundant nested directories (java-server/java-server → java-server) 21 - Added run.sh scripts for easy execution 22 23 ### 4. Comprehensive Test Suite 24 Added client_test.go with test cases covering: 25 - Dubbo Protocol Tests (6 cases) 26 - Triple Protocol Tests (13 cases) 27 - Benchmarks for both protocols 28 29 ### 5. Code Improvements 30 - Go server uses direct connection mode (no registry) 31 - user_provider.go Invoke method returns proper error for unknown methods 32 - Fixed QueryUsers parameter type to match Java array signature 33 34 ## Dependencies 35 This PR depends on apache/dubbo-go#3154 which adds `NewGenericService` API. 36 CI will pass after that PR is merged to main branch. 37 38 Signed-off-by: TsukiKage <chongyanx@163.com>
1 parent a6246b2 commit 28d3472

File tree

5 files changed

+13
-8
lines changed

5 files changed

+13
-8
lines changed

generic/go-client/cmd/client.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,13 @@ import (
3131

3232
hessian "github.com/apache/dubbo-go-hessian2"
3333

34-
"github.com/apache/dubbo-go-samples/generic/go-client/pkg"
35-
3634
"github.com/dubbogo/gost/log/logger"
3735
)
3836

37+
import (
38+
"github.com/apache/dubbo-go-samples/generic/go-client/pkg"
39+
)
40+
3941
const (
4042
DubboServerURL = "dubbo://127.0.0.1:20000"
4143
TripleServerURL = "tri://127.0.0.1:50052"

generic/go-client/cmd/client_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ import (
3131
_ "dubbo.apache.org/dubbo-go/v3/imports"
3232

3333
hessian "github.com/apache/dubbo-go-hessian2"
34+
)
3435

36+
import (
3537
"github.com/apache/dubbo-go-samples/generic/go-client/pkg"
3638
)
3739

generic/go-server/cmd/server.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@ import (
2727

2828
hessian "github.com/apache/dubbo-go-hessian2"
2929

30-
"github.com/apache/dubbo-go-samples/generic/go-server/pkg"
31-
3230
"github.com/dubbogo/gost/log/logger"
3331
)
3432

33+
import (
34+
"github.com/apache/dubbo-go-samples/generic/go-server/pkg"
35+
)
36+
3537
func main() {
3638
hessian.RegisterPOJO(&pkg.User{})
3739

go.mod

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ require (
8585
github.com/hashicorp/hcl v1.0.0 // indirect
8686
github.com/hashicorp/vault/sdk v0.7.0 // indirect
8787
github.com/influxdata/tdigest v0.0.1 // indirect
88-
github.com/jinzhu/copier v0.3.5 // indirect
8988
github.com/jmespath/go-jmespath v0.4.0 // indirect
9089
github.com/json-iterator/go v1.1.12 // indirect
9190
github.com/k0kubun/pp v3.0.1+incompatible // indirect
@@ -173,7 +172,7 @@ require (
173172
)
174173

175174
replace (
176-
dubbo.apache.org/dubbo-go/v3 => ../dubbo-go
175+
dubbo.apache.org/dubbo-go/v3 => github.com/apache/dubbo-go/v3 v3.0.0-20260210015753-35ea886421f9
177176
go.opentelemetry.io/otel => go.opentelemetry.io/otel v1.26.0
178177
go.opentelemetry.io/otel/exporters/otlp/otlptrace => go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.21.0
179178
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc => go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.21.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,8 @@ github.com/apache/dubbo-go-hessian2 v1.9.1/go.mod h1:xQUjE7F8PX49nm80kChFvepA/Av
832832
github.com/apache/dubbo-go-hessian2 v1.9.3/go.mod h1:xQUjE7F8PX49nm80kChFvepA/AvqAZ0oh/UaB6+6pBE=
833833
github.com/apache/dubbo-go-hessian2 v1.12.5 h1:19lJz2Md0EYF2bOtEvFqXEQRYvLz04GfsoocsBWlLWQ=
834834
github.com/apache/dubbo-go-hessian2 v1.12.5/go.mod h1:QP9Tc0w/B/mDopjusebo/c7GgEfl6Lz8jeuFg8JA6yw=
835+
github.com/apache/dubbo-go/v3 v3.0.0-20260210015753-35ea886421f9 h1:z9gt++7EVCWbMsCMedweVcjnK1OxmVq4Bj1DSnw92Hs=
836+
github.com/apache/dubbo-go/v3 v3.0.0-20260210015753-35ea886421f9/go.mod h1:3ggdIDIW72EmHD2hX9rfCULcKHlaRMSCXWUjAQ9exII=
835837
github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
836838
github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
837839
github.com/apache/thrift v0.16.0/go.mod h1:PHK3hniurgQaNMZYaCLEqXKsYK8upmhPbmdP2FXSqgU=
@@ -1384,8 +1386,6 @@ github.com/jehiah/go-strftime v0.0.0-20171201141054-1d33003b3869/go.mod h1:cJ6Cj
13841386
github.com/jellevandenhooff/dkim v0.0.0-20150330215556-f50fe3d243e1/go.mod h1:E0B/fFc00Y+Rasa88328GlI/XbtyysCtTHZS8h7IrBU=
13851387
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
13861388
github.com/jhump/protoreflect v1.6.0/go.mod h1:eaTn3RZAmMBcV0fifFvlm6VHNz3wSkYyXYWUh7ymB74=
1387-
github.com/jinzhu/copier v0.3.5 h1:GlvfUwHk62RokgqVNvYsku0TATCF7bAHVwEXoBh3iJg=
1388-
github.com/jinzhu/copier v0.3.5/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg=
13891389
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
13901390
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
13911391
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=

0 commit comments

Comments
 (0)