This is an automated email from the ASF dual-hosted git repository.
alexstocks pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/dubbo-go-samples.git
The following commit(s) were added to refs/heads/main by this push:
new 567b8912 feat: upgrade dubbo-go version to latest (#999)
567b8912 is described below
commit 567b891292d8b8e049fbe9f56fc864fe7a3a10a7
Author: 陈乐樂 <[email protected]>
AuthorDate: Sat Dec 20 15:09:22 2025 +0800
feat: upgrade dubbo-go version to latest (#999)
* upgrade dubbo-go to latest
---------
Co-authored-by: Xuetao Li <[email protected]>
Co-authored-by: Xin.Zh <[email protected]>
---
README.md | 4 +-
README_CN.md | 4 +-
direct/README.md | 40 ++++++++--
direct/README_zh.md | 45 +++++++++--
direct/go-client/cmd/main.go | 22 ++++--
direct/go-server/cmd/main.go | 1 +
direct/java-client/pom.xml | 72 +++++++++++++++++
direct/java-client/run.sh | 3 +
.../java/org/example/client/JavaClientApp.java | 56 ++++++++++++++
.../src/main/proto/greet.proto} | 45 ++++-------
direct/java-server/pom.xml | 72 +++++++++++++++++
direct/java-server/run.sh | 3 +
.../java/org/example/server/JavaServerApp.java | 58 ++++++++++++++
.../src/main/proto/greet.proto} | 46 ++++-------
direct/pom.xml | 89 ++++++++++++++++++++++
go.mod | 4 +-
go.sum | 8 +-
17 files changed, 480 insertions(+), 92 deletions(-)
diff --git a/README.md b/README.md
index 869b7c14..cd6fec9f 100644
--- a/README.md
+++ b/README.md
@@ -20,7 +20,7 @@ A collection of runnable Dubbo-go examples covering
configuration, registries, o
* `polaris/limit`: Uses Polaris as a TPS limiter.
* `healthcheck`: Service health check example.
* `helloworld`: Basic “Hello World” example for Dubbo-go, also includes
Go–Java interoperability.
-* `direct`: Triple point-to-point invocation sample without a registry.
+* `direct`: Triple point-to-point invocation sample without a registry, also
includes Go–Java interoperability.
* `game`: Game service example.
* `generic`: Generic invocation examples supporting interoperability between
Dubbo-Go and Dubbo Java services, suitable for scenarios without interface
information.
* `integrate_test`: Integration test cases for Dubbo-go samples.
@@ -39,7 +39,7 @@ A collection of runnable Dubbo-go examples covering
configuration, registries, o
* `rpc/grpc`: gRPC protocol example.
* `rpc/jsonrpc`: JSON-RPC protocol example.
* `rpc/triple`: Triple protocol example with multiple serialization formats.
-* `streaming`: Streaming RPC example.
+* `streaming`: Streaming RPC example, also includes Go–Java interoperability
when both use streaming.
* `task`: Task scheduling and execution example.
* `timeout`: Demonstrates timeout handling in Dubbo-go.
* `tls`: Demonstrates how to use TLS (based on X.509 certificates) in Dubbo-go
to enable encrypted communication and/or mutual authentication between client
and server.
diff --git a/README_CN.md b/README_CN.md
index e83ea2a5..d9f2f81a 100644
--- a/README_CN.md
+++ b/README_CN.md
@@ -20,7 +20,7 @@
* `polaris/limit`:使用 Polaris 实现 TPS 限流。
* `healthcheck`:服务健康检查示例。
* `helloworld`:Dubbo-go 最基础的 “Hello World” 示例,同时包含 Go 与 Java 的互操作示例。
-* `direct`:不依赖注册中心的 Triple 点对点调用示例。
+* `direct`:不依赖注册中心的 Triple 点对点调用示例,并包含 Go 与 Java 的互操作示例。
* `game`:游戏服务示例。
* `generic`:泛化调用示例,支持 Dubbo-Go 与 Dubbo Java 服务互操作,适用于无接口信息场景。
* `integrate_test`:Dubbo-go 示例的集成测试用例。
@@ -39,7 +39,7 @@
* `rpc/grpc`:基于 gRPC 协议的示例。
* `rpc/jsonrpc`:基于 JSON-RPC 协议的示例。
* `rpc/triple`:Triple 协议示例,涵盖多种序列化方式。
-* `streaming`:流式 RPC 调用示例。
+* `streaming`:流式 RPC 调用示例, 并包含了Dubbo-go与Dubbo-java同时使用流式传输的互操作示例。
* `task`:任务调度与执行示例。
* `timeout`:Dubbo-go 超时处理示例。
* `tls`:演示如何在 Dubbo-go 中使用 TLS(基于 X.509 证书),实现客户端与服务端之间的加密通信和/或双向认证。
diff --git a/direct/README.md b/direct/README.md
index 3efc7002..8b9a92bb 100644
--- a/direct/README.md
+++ b/direct/README.md
@@ -10,10 +10,12 @@ This sample demonstrates how to use the Dubbo-Go v3 triple
API to perform a poin
direct/
├── proto/ # greet proto definition and generated triple stubs
├── go-server/ # triple provider listening on :20000
-└── go-client/ # consumer dialing the provider directly
+├── go-client/ # consumer dialing the provider directly
+├── java-server/ # triple provider listening on :20000
+└── java-client/ # consumer dialing the provider directly
```
-## Run the provider
+## Run the Golang provider
```bash
cd direct/go-server/cmd
@@ -22,7 +24,7 @@ go run .
The server uses the triple protocol on port `20000` and implements
`greet.GreetService`.
-## Run the consumer
+## Run the Golang consumer
```bash
cd direct/go-client/cmd
@@ -31,16 +33,42 @@ go run .
`go-client` creates a triple client with
`client.WithClientURL("tri://127.0.0.1:20000")`, so it does not require any
registry or application-level configuration files.
+## Run the Java Provider
+
+Build all Java modules from the root directory:
+(if theres no Maven in your computer,you should install [Maven][])
+```shell
+mvn clean compile
+cd java-server
+mvn exec:java "-Dexec.mainClass=org.example.server.JavaServerApp"
+```
+
+## Run the Java Consumer
+
+Build all Java modules from the root directory:
+(if theres no Maven in your computer,you should install [Maven][])
+```shell
+mvn clean compile
+cd java-client
+mvn exec:java "-Dexec.mainClass=org.example.server.JavaClientApp"
+```
+
## Expected output
Provider log:
```
-INFO ... Direct server received name = dubbo-go
+INFO ... Direct server form Golang/Java received name = Golang Client
dubbo-go/Java Client dubbo
```
Consumer log:
```
-INFO ... direct call response: hello dubbo-go
-```
\ No newline at end of file
+INFO ... direct call response: Hello form Java/Golang Server, Golang Client
dubbo-go/Java Client dubbo
+```
+
+## Attention
+
+Do NOT Start Go Server and Java Server at the Same Time. Both the Go server
and Java server listen on the same port: 20000 and expose the same Triple
service path:greet.GreetService/Greet
+
+[Maven]: https://maven.apache.org/download.cgi
\ No newline at end of file
diff --git a/direct/README_zh.md b/direct/README_zh.md
index 96420e57..ac10cfed 100644
--- a/direct/README_zh.md
+++ b/direct/README_zh.md
@@ -9,11 +9,13 @@
```
direct/
├── proto/ # greet.proto 以及对应的 triple 代码
-├── go-server/ # 提供 greet.GreetService 的服务端
-└── go-client/ # 直接拨号 tri://127.0.0.1:20000 的客户端
+├── go-server/ # 提供 greet.GreetService 的Golang服务端
+├── go-client/ # 直接拨号 tri://127.0.0.1:20000 的Golang客户端
+├── java-server/ # 提供 greet.GreetService 的Java服务端
+└── java-client/ # 直接拨号 tri://127.0.0.1:20000 的Java客户端
```
-## 启动服务端
+## 启动Golang服务端
```bash
cd direct/go-server/cmd
@@ -22,7 +24,7 @@ go run .
服务端监听 `20000` 端口,并实现 `greet.GreetService` 的 `Greet` 方法。
-## 启动客户端
+## 启动Golang客户端
```bash
cd direct/go-client/cmd
@@ -31,16 +33,45 @@ go run .
客户端通过 `client.WithClientURL` 配置直连地址,无需任何 yaml 配置,也无需注册中心即可完成调用。
+## 启动Java服务端
+
+从根目录构建所有 Java 模块:
+(如没有安装 `Maven` ,请先安装[Maven][])
+```shell
+mvn clean compile
+cd java-server
+mvn exec:java "-Dexec.mainClass=org.example.server.JavaServerApp"
+```
+
+## 启动Java客户端
+
+从根目录构建所有 Java 模块:
+(如没有安装 `Maven` ,请先安装[Maven][])
+```shell
+mvn clean compile
+cd java-client
+mvn exec:java "-Dexec.mainClass=org.example.client.JavaClientApp"
+```
+
## 预期输出
服务端日志:
```
-INFO ... Direct server received name = dubbo-go
+INFO ... Direct server form Golang/Java received name = Golang Client
dubbo-go/Java Client dubbo
```
客户端日志:
```
-INFO ... direct call response: hello dubbo-go
-```
\ No newline at end of file
+INFO ... direct call response: Hello form Java/Golang Server, Golang Client
dubbo-go/Java Client dubbo
+```
+
+## 注意
+
+由于Golang/Java Server都在监听20000端口,你不能同时打开Golang Server和Java Server
+
+
+
+
+[Maven]: https://maven.apache.org/download.cgi
\ No newline at end of file
diff --git a/direct/go-client/cmd/main.go b/direct/go-client/cmd/main.go
index bdaf8dae..d6107282 100644
--- a/direct/go-client/cmd/main.go
+++ b/direct/go-client/cmd/main.go
@@ -37,19 +37,31 @@ func main() {
client.WithClientURL("tri://127.0.0.1:20000"),
)
if err != nil {
- panic(err)
+ panic(err) // fail fast if client cannot be created
}
greetService, err := greet.NewGreetService(cli)
if err != nil {
- panic(err)
+ panic(err) // fail fast if service proxy cannot be created
}
- req := &greet.GreetRequest{Name: "dubbo-go"}
+ // Direct call: 1 request -> 1 response
+ name := "Golang Client dubbo-go"
+ req := &greet.GreetRequest{Name: name}
resp, err := greetService.Greet(context.Background(), req)
if err != nil {
- logger.Errorf("direct call failed: %v", err)
- return
+ panic(err)
+ }
+ if resp == nil {
+ panic("direct call failed: empty response")
}
+
+ // Go 服务返回 "hello {name}",Java 示例服务返回 "hello from java server, {name}"
+ expectGo := "hello " + name
+ expectJava := "hello from java server, " + name
+ if resp.Greeting != expectGo && resp.Greeting != expectJava {
+ panic("unexpected greeting: " + resp.Greeting)
+ }
+
logger.Infof("direct call response: %s", resp.Greeting)
}
diff --git a/direct/go-server/cmd/main.go b/direct/go-server/cmd/main.go
index 10375cfb..e2be1dfc 100644
--- a/direct/go-server/cmd/main.go
+++ b/direct/go-server/cmd/main.go
@@ -35,6 +35,7 @@ import (
type DirectGreetServer struct{}
+// Greet: 1 request -> 1 response, returns "hello {name}"
func (s *DirectGreetServer) Greet(ctx context.Context, req
*greet.GreetRequest) (*greet.GreetResponse, error) {
logger.Infof("Direct server received name = %s", req.Name)
return &greet.GreetResponse{Greeting: "hello " + req.Name}, nil
diff --git a/direct/java-client/pom.xml b/direct/java-client/pom.xml
new file mode 100644
index 00000000..9e778431
--- /dev/null
+++ b/direct/java-client/pom.xml
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <groupId>org.example</groupId>
+ <artifactId>helloworld-parent</artifactId>
+ <version>1.0.0</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>java-greet-client</artifactId>
+ <name>java-greet-client</name>
+ <description>Java client module for helloworld</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>com.google.protobuf</groupId>
+ <artifactId>protobuf-java</artifactId>
+ <version>${protobuf.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>io.grpc</groupId>
+ <artifactId>grpc-stub</artifactId>
+ <version>${grpc.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>io.grpc</groupId>
+ <artifactId>grpc-protobuf</artifactId>
+ <version>${grpc.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>io.grpc</groupId>
+ <artifactId>grpc-netty-shaded</artifactId>
+ <version>${grpc.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.xolstice.maven.plugins</groupId>
+ <artifactId>protobuf-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>3.1.0</version>
+ <configuration>
+ <mainClass>org.example.client.JavaClientApp</mainClass>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
diff --git a/direct/java-client/run.sh b/direct/java-client/run.sh
new file mode 100644
index 00000000..18af5dbc
--- /dev/null
+++ b/direct/java-client/run.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+mvn -q clean package
+mvn -q exec:java -Dexec.mainClass=org.example.client.JavaClientApp
diff --git
a/direct/java-client/src/main/java/org/example/client/JavaClientApp.java
b/direct/java-client/src/main/java/org/example/client/JavaClientApp.java
new file mode 100644
index 00000000..80e2e2f0
--- /dev/null
+++ b/direct/java-client/src/main/java/org/example/client/JavaClientApp.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.example.client;
+
+import greet.GreetRequest;
+import greet.GreetResponse;
+import greet.GreetServiceGrpc;
+
+import io.grpc.ManagedChannel;
+import io.grpc.ManagedChannelBuilder;
+
+public class JavaClientApp {
+
+ public static void main(String[] args) {
+
+ ManagedChannel channel = ManagedChannelBuilder
+ .forAddress("127.0.0.1", 20000)
+ .usePlaintext()
+ .build();
+
+ GreetServiceGrpc.GreetServiceBlockingStub client =
+ GreetServiceGrpc.newBlockingStub(channel);
+
+ // Direct call: 1 request -> 1 response
+ GreetRequest req = GreetRequest.newBuilder()
+ .setName("Java Client Dubbo")
+ .build();
+
+ GreetResponse resp = client.greet(req);
+
+ String expectedGo = "hello " + req.getName();
+ String expectedJava = "hello from java server, " + req.getName();
+ if (resp == null || (!expectedGo.equals(resp.getGreeting()) &&
!expectedJava.equals(resp.getGreeting()))) {
+ throw new IllegalStateException("Unexpected greeting: " + resp);
+ }
+
+ System.out.println("Response: " + resp.getGreeting());
+
+ channel.shutdown();
+ }
+}
diff --git a/direct/go-client/cmd/main.go
b/direct/java-client/src/main/proto/greet.proto
similarity index 54%
copy from direct/go-client/cmd/main.go
copy to direct/java-client/src/main/proto/greet.proto
index bdaf8dae..28982b54 100644
--- a/direct/go-client/cmd/main.go
+++ b/direct/java-client/src/main/proto/greet.proto
@@ -15,41 +15,22 @@
* limitations under the License.
*/
-package main
+syntax = "proto3";
-import (
- "context"
-)
+package greet;
-import (
- "dubbo.apache.org/dubbo-go/v3/client"
- _ "dubbo.apache.org/dubbo-go/v3/imports"
+option go_package = "./greet";
+option java_package = "greet";
+option java_multiple_files = true;
- "github.com/dubbogo/gost/log/logger"
-)
-
-import (
- greet "github.com/apache/dubbo-go-samples/direct/proto"
-)
-
-func main() {
- cli, err := client.NewClient(
- client.WithClientURL("tri://127.0.0.1:20000"),
- )
- if err != nil {
- panic(err)
- }
+message GreetRequest {
+ string name = 1;
+}
- greetService, err := greet.NewGreetService(cli)
- if err != nil {
- panic(err)
- }
+message GreetResponse {
+ string greeting = 1;
+}
- req := &greet.GreetRequest{Name: "dubbo-go"}
- resp, err := greetService.Greet(context.Background(), req)
- if err != nil {
- logger.Errorf("direct call failed: %v", err)
- return
- }
- logger.Infof("direct call response: %s", resp.Greeting)
+service GreetService {
+ rpc Greet(GreetRequest) returns (GreetResponse);
}
diff --git a/direct/java-server/pom.xml b/direct/java-server/pom.xml
new file mode 100644
index 00000000..2d8853ce
--- /dev/null
+++ b/direct/java-server/pom.xml
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <groupId>org.example</groupId>
+ <artifactId>helloworld-parent</artifactId>
+ <version>1.0.0</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>java-greet-server</artifactId>
+ <name>java-greet-server</name>
+ <description>Java server module for helloworld</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>com.google.protobuf</groupId>
+ <artifactId>protobuf-java</artifactId>
+ <version>${protobuf.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>io.grpc</groupId>
+ <artifactId>grpc-stub</artifactId>
+ <version>${grpc.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>io.grpc</groupId>
+ <artifactId>grpc-protobuf</artifactId>
+ <version>${grpc.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>io.grpc</groupId>
+ <artifactId>grpc-netty-shaded</artifactId>
+ <version>${grpc.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.xolstice.maven.plugins</groupId>
+ <artifactId>protobuf-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>3.1.0</version>
+ <configuration>
+ <mainClass>org.example.server.JavaServerApp</mainClass>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
diff --git a/direct/java-server/run.sh b/direct/java-server/run.sh
new file mode 100644
index 00000000..acfc7a36
--- /dev/null
+++ b/direct/java-server/run.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+mvn -q clean package
+mvn -q exec:java -Dexec.mainClass=org.example.server.JavaGreetServer
diff --git
a/direct/java-server/src/main/java/org/example/server/JavaServerApp.java
b/direct/java-server/src/main/java/org/example/server/JavaServerApp.java
new file mode 100644
index 00000000..634a6435
--- /dev/null
+++ b/direct/java-server/src/main/java/org/example/server/JavaServerApp.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.example.server;
+
+import greet.GreetRequest;
+import greet.GreetResponse;
+import greet.GreetServiceGrpc;
+
+import io.grpc.Server;
+import io.grpc.ServerBuilder;
+import io.grpc.stub.StreamObserver;
+
+public class JavaServerApp {
+
+ public static void main(String[] args) throws Exception {
+
+ Server server = ServerBuilder.forPort(20000)
+ .addService(new GreetServiceGrpc.GreetServiceImplBase() {
+
+ // Greet: 1 request -> 1 response, returns "hello from
java server, {name}"
+ @Override
+ public void greet(GreetRequest request,
+ StreamObserver<GreetResponse>
respObserver) {
+
+ String name = request.getName();
+
+ System.out.println("Direct server form Java received
name ="+ name);
+
+ GreetResponse resp = GreetResponse.newBuilder()
+ .setGreeting("hello from java server, " + name)
+ .build();
+
+ respObserver.onNext(resp);
+ respObserver.onCompleted();
+ }
+ })
+ .build();
+
+ server.start();
+ System.out.println("Java Triple Server started on port 20000");
+ server.awaitTermination();
+ }
+}
diff --git a/direct/go-client/cmd/main.go
b/direct/java-server/src/main/proto/greet.proto
similarity index 54%
copy from direct/go-client/cmd/main.go
copy to direct/java-server/src/main/proto/greet.proto
index bdaf8dae..00830292 100644
--- a/direct/go-client/cmd/main.go
+++ b/direct/java-server/src/main/proto/greet.proto
@@ -15,41 +15,23 @@
* limitations under the License.
*/
-package main
+syntax = "proto3";
-import (
- "context"
-)
+package greet;
-import (
- "dubbo.apache.org/dubbo-go/v3/client"
- _ "dubbo.apache.org/dubbo-go/v3/imports"
+option go_package = "github.com/apache/dubbo-go-samples/direct/proto;greet";
+option java_package = "greet";
+option java_multiple_files = true;
- "github.com/dubbogo/gost/log/logger"
-)
-
-import (
- greet "github.com/apache/dubbo-go-samples/direct/proto"
-)
-
-func main() {
- cli, err := client.NewClient(
- client.WithClientURL("tri://127.0.0.1:20000"),
- )
- if err != nil {
- panic(err)
- }
+message GreetRequest {
+ string name = 1;
+}
- greetService, err := greet.NewGreetService(cli)
- if err != nil {
- panic(err)
- }
+message GreetResponse {
+ string greeting = 1;
+}
- req := &greet.GreetRequest{Name: "dubbo-go"}
- resp, err := greetService.Greet(context.Background(), req)
- if err != nil {
- logger.Errorf("direct call failed: %v", err)
- return
- }
- logger.Infof("direct call response: %s", resp.Greeting)
+// gRPC/Dubbo-Triple
+service GreetService {
+ rpc Greet(GreetRequest) returns (GreetResponse);
}
diff --git a/direct/pom.xml b/direct/pom.xml
new file mode 100644
index 00000000..2d6939dd
--- /dev/null
+++ b/direct/pom.xml
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.example</groupId>
+ <artifactId>helloworld-parent</artifactId>
+ <version>1.0.0</version>
+ <packaging>pom</packaging>
+ <name>helloworld-parent</name>
+ <description>Parent POM for helloworld project</description>
+
+ <modules>
+ <module>java-client</module>
+ <module>java-server</module>
+ </modules>
+
+ <properties>
+ <protobuf.version>3.21.7</protobuf.version>
+ <grpc.version>1.51.0</grpc.version>
+ <maven.compiler.source>11</maven.compiler.source>
+ <maven.compiler.target>11</maven.compiler.target>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>javax.annotation</groupId>
+ <artifactId>javax.annotation-api</artifactId>
+ <version>1.3.2</version>
+ </dependency>
+ </dependencies>
+
+
+ <build>
+ <extensions>
+ <extension>
+ <groupId>kr.motd.maven</groupId>
+ <artifactId>os-maven-plugin</artifactId>
+ <version>1.7.0</version>
+ </extension>
+ </extensions>
+
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.xolstice.maven.plugins</groupId>
+ <artifactId>protobuf-maven-plugin</artifactId>
+ <version>0.6.1</version>
+ <configuration>
+ <protocArtifact>
+
com.google.protobuf:protoc:${protobuf.version}:exe:windows-x86_64
+ </protocArtifact>
+ <pluginId>grpc-java</pluginId>
+ <pluginArtifact>
+
io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:windows-x86_64
+ </pluginArtifact>
+
<protoSourceRoot>${project.basedir}/src/main/proto</protoSourceRoot>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>compile</goal>
+ <goal>compile-custom</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+</project>
\ No newline at end of file
diff --git a/go.mod b/go.mod
index 9d6f3539..2262e3ea 100644
--- a/go.mod
+++ b/go.mod
@@ -3,11 +3,11 @@ module github.com/apache/dubbo-go-samples
go 1.24.0
require (
- dubbo.apache.org/dubbo-go/v3 v3.3.1-0.20251028122905-48c55c00b702
+ dubbo.apache.org/dubbo-go/v3 v3.3.0-20251220
github.com/alibaba/sentinel-golang v1.0.4
github.com/apache/dubbo-go-hessian2 v1.12.5
github.com/dubbogo/go-zookeeper v1.0.4-0.20211212162352-f9d2183d89d5
- github.com/dubbogo/gost v1.14.1
+ github.com/dubbogo/gost v1.14.3
github.com/dubbogo/grpc-go v1.42.10
github.com/dubbogo/triple v1.2.2-rc4
github.com/gin-contrib/sessions v1.0.2
diff --git a/go.sum b/go.sum
index ec0e9f49..57cc91a1 100644
--- a/go.sum
+++ b/go.sum
@@ -42,8 +42,8 @@ cloud.google.com/go/storage v1.14.0/go.mod
h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3f
contrib.go.opencensus.io/exporter/prometheus v0.4.1/go.mod
h1:t9wvfitlUjGXG2IXAZsuFq26mDGid/JwCEXp+gTG/9U=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod
h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
dubbo.apache.org/dubbo-go/v3 v3.0.2-0.20220508105316-b27ec53b7bab/go.mod
h1:Ytn9MtmsFYkpa1bzW/3loUFBgm7eJ3M3+XWRurhbBZc=
-dubbo.apache.org/dubbo-go/v3 v3.3.1-0.20251028122905-48c55c00b702
h1:WKuiT4KrpwcnzYPY/S2ItjdOCHwMo5mtrS/68uJoutE=
-dubbo.apache.org/dubbo-go/v3 v3.3.1-0.20251028122905-48c55c00b702/go.mod
h1:LB1N3QXiE1ZATzBgb899dQnSqjlQoi0DPPMyYMervSM=
+dubbo.apache.org/dubbo-go/v3 v3.3.0-20251220
h1:7b+wqUQoHdFWvBcENECy+eabgd76551sc4pedWhnG64=
+dubbo.apache.org/dubbo-go/v3 v3.3.0-20251220/go.mod
h1:va59d5/A3OD41YyxJ1cijhKV5ABV1OZxgjncWV+K8Ys=
github.com/BurntSushi/toml v0.3.1/go.mod
h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/toml v1.1.0
h1:ksErzDEI1khOiGPgpwuI7x2ebx/uXQNw7xJpn9Eq1+I=
github.com/BurntSushi/toml v1.1.0/go.mod
h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
@@ -225,8 +225,8 @@ github.com/dubbogo/gost v1.11.23/go.mod
h1:PhJ8+qZJx+Txjx1KthNPuVkCvUca0jRLgKWj/
github.com/dubbogo/gost v1.11.25/go.mod
h1:iovrPhv0hyakhQGVr4jwiECBL9HXNuBY4VV3HWK5pM0=
github.com/dubbogo/gost v1.12.5/go.mod
h1:f0bcP1xpBUdDgiNjNYKF6F3qlA+RFKs0k980FhoEn/g=
github.com/dubbogo/gost v1.13.1/go.mod
h1:9HMXBv+WBMRWhF3SklpqDjkS/01AKWm2SrVdz/A0xJI=
-github.com/dubbogo/gost v1.14.1 h1:veA+5FqwUHvqaB5OPvsWz4iDkGGpyL4lig2rSOZANEs=
-github.com/dubbogo/gost v1.14.1/go.mod
h1:m3VJVqCjQ87SwYRrxN2s4T33cOCDrMVbRh4+MAUitnQ=
+github.com/dubbogo/gost v1.14.3 h1:bInkIjdImMo9ENTDdCcs4YlQ/vz5rP/rjcnLakK5x24=
+github.com/dubbogo/gost v1.14.3/go.mod
h1:WydBuEOkwKEm9mcWLlOnmsVe1ELFgrNPmC5SzXdPv4A=
github.com/dubbogo/grpc-go v1.42.9/go.mod
h1:F1T9hnUvYGW4JLK1QNriavpOkhusU677ovPzLkk6zHM=
github.com/dubbogo/grpc-go v1.42.10
h1:CoyCdtqKJEar/3rPa6peZbDqYZ/mVsCqAxB6TfTSkhQ=
github.com/dubbogo/grpc-go v1.42.10/go.mod
h1:JMkPt1mIHL96GAFeYsMoMjew6f1ROKycikGzZQH1s5U=