This is an automated email from the ASF dual-hosted git repository.

xuetaoli 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 61d22b71 feat: migrate old direct to new (#961)
61d22b71 is described below

commit 61d22b71ad5cb3a7b21578bbdac56414b9622ec2
Author: zbchi <[email protected]>
AuthorDate: Tue Nov 18 20:51:10 2025 +0800

    feat: migrate old direct to new (#961)
    
    * feat: migrate old direct
---
 README.md                                          |   2 +-
 README_CN.md                                       |   2 +-
 compatibility/direct/README.md                     | 170 ---------------
 compatibility/direct/README_zh.md                  | 171 ---------------
 compatibility/direct/go-client/conf/dubbogo.yml    |   6 -
 compatibility/direct/go-server/conf/dubbogo.yml    |   9 -
 direct/README.md                                   |  49 +++++
 direct/README_zh.md                                |  94 +++++++++
 .../cmd/client.go => direct/go-client/cmd/main.go  |  28 +--
 .../cmd/server.go => direct/go-server/cmd/main.go  |  34 +--
 direct/proto/greet.pb.go                           | 230 +++++++++++++++++++++
 .../main_test.go => direct/proto/greet.proto       |  34 ++-
 direct/proto/greet.triple.go                       | 122 +++++++++++
 .../direct/tests/integration/main_test.go          |  18 +-
 .../direct/tests/integration/userprovider_test.go  |  16 +-
 start_integrate_test.sh                            |   2 +-
 16 files changed, 566 insertions(+), 421 deletions(-)

diff --git a/README.md b/README.md
index 7f97d272..c1d2e363 100644
--- a/README.md
+++ b/README.md
@@ -11,7 +11,6 @@
 * compatibility/async: Callback (asynchronous) and one-way RPC example
 * compatibility/config-api: How to use Dubbo-go by APIs without configuration 
files
 * compatibility/configcenter: Usage of different config centers, including 
zookeeper, nacos and apollo
-* compatibility/direct: Direct invocation example
 * compatibility/filter: Examples of different filters, including custom_filter 
and tpslimit
 * compatibility/game: Game service example
 * compatibility/generic: Generic invocation example
@@ -36,6 +35,7 @@
 * filter: Demonstrates the use of built-in and custom filters in Dubbo-go
   * polaris/limit: Use Polaris as tps limiter
 * healthcheck: Service health check example
+* direct: Triple point-to-point invocation sample without registry
 * helloworld: Basic hello world example for Dubbo-go
 * integrate_test: Integration test cases for Dubbo-go samples
 * java_interop: Demonstrates interoperability between Java and Go Dubbo 
implementations
diff --git a/README_CN.md b/README_CN.md
index 0aa7e679..262b1faa 100644
--- a/README_CN.md
+++ b/README_CN.md
@@ -7,7 +7,6 @@
 * compatibility/async:通过 callback 方式进行异步 RPC 及单向调用示例
 * compatibility/config-api:无需配置文件,使用 API 启动 Dubbo-go 服务
 * compatibility/configcenter:多种配置中心(如 zookeeper、nacos、apollo)用法示例
-* compatibility/direct:直连调用示例,无需注册中心
 * compatibility/filter:内置及自定义 filter 示例(如 custom_filter、tpslimit)
 * compatibility/game:游戏服务示例
 * compatibility/generic:泛化调用示例
@@ -32,6 +31,7 @@
 * filter:内置及自定义 filter 用法示例
   * polaris/limit: 使用Polaris的服务限流功能示例
 * healthcheck:服务健康检查示例
+* direct:Triple 直连示例,无需注册中心
 * helloworld:Dubbo-go 入门 Hello World 示例
 * integrate_test:Dubbo-go 示例集成测试用例
 * java_interop:Java 与 Go Dubbo 实现互操作示例
diff --git a/compatibility/direct/README.md b/compatibility/direct/README.md
deleted file mode 100644
index c5fe16d2..00000000
--- a/compatibility/direct/README.md
+++ /dev/null
@@ -1,170 +0,0 @@
-# Direct Example
-
-### Backend
-
-In the development and testing environment, it is often necessary to bypass 
the registry and test the designated service provider, which may require 
point-to-point direct connection. The point-to-point direct connection method 
will be based on the service interface and ignore the list of providers in the 
registry. Interface A is configured point-to-point and does not affect 
interface B to get the list from the registry.
-
-This example provides the `Consumer` point-to-point direct connection 
`Provider` based on Dubbo-Go to complete service calls to help better 
understand the connectivity of Dubbo-Go.
-
-### Introduction
-
-```
-├── go-client     
-│   ├── cmd       
-│   ├── conf      
-│   └── pkg         
-└── go-server     
-    ├── cmd       
-    ├── conf      
-    ├── docker     
-    ├── pkg
-    └── tests
-        └── integration
-```
-
-- go-server: The Service Provider
-- go-client: The Service Consumer
-
-#### Provider
-Direct example code description:
-
-1. Configure the Dubbo protocol, registry, service information, See 
[server.yml](go-server/conf/server.yml)
-
-```yaml
-services:
-  "UserProvider":
-    registry-ids: "demoZk"
-    protocol : "dubbo"
-    interface : "org.apache.dubbo.UserProvider"
-    loadbalance: "random"
-    warmup: "100"
-    cluster: "failover"
-    methods:
-    - name: "GetUser"
-      retries: 1
-      loadbalance: "random"
-```
-
-2. Startup: Register the service
-
-```go
-hessian.RegisterPOJO(&pkg.User{})
-config.Load()
-initSignal()
-```
-
-- Based on the `hessian` serialization protocol, using 
[apache/dubbo-go-hessian2](https://github.com/apache/dubbo-go-hessian2) 
RegisterPOJO register a POJO
-- Dubbo Init: Registration service, See 
[apache/dubbo-go/../config_loader.go](https://dubbo.apache.org/dubbo-go/v3/blob/master/config/config_loader.go)
-    - init router
-    - init the global event dispatcher
-    - start the metadata report if config set
-    - reference config
-    - service config
-    - init the shutdown callback
-- Init Signal :
-  
-    ```go
-    func initSignal() {
-        signals := make(chan os.Signal, 1)
-        // It is not possible to block SIGKILL or syscall.SIGSTOP
-        signal.Notify(signals, os.Interrupt, syscall.SIGHUP, syscall.SIGQUIT, 
syscall.SIGTERM)
-        for {
-            sig := <-signals
-            logger.Infof("get signal %s", sig.String())
-            switch sig {
-            case syscall.SIGHUP:
-                // reload()
-            default:
-                time.AfterFunc(time.Duration(survivalTimeout), func() {
-                    logger.Warnf("app exit now by force...")
-                    os.Exit(1)
-                })
-    
-                // The program exits normally or timeout forcibly exits.
-                fmt.Println("provider app exit now...")
-                return
-            }
-        }
-    }
-    ```
-
-#### Consumer
-
-1. Set up the `dubbo service` you need to subscribe to at the beginning of the 
program startup.
-   Make sure that the configuration file 
[dubbogo.yml](go-client/conf/dubbogo.yml) has been configured with the relevant 
information of the subscription service, and the service properties can be 
customized to override the configuration of the Provider's properties.
-   Retain minimum configuration `application` and `references` verification 
point-to-point direct connection effect, no need to configure the registry.
-
-```go
-var userProvider = new(pkg.UserProvider)
-
-func init() {
-    config.SetConsumerService(userProvider)
-    hessian.RegisterPOJO(&pkg.User{})
-}
-```
-
-```yaml
-application:
-  organization: "dubbo.io"
-  name: "UserInfoClient"
-  module: "dubbo-go user-info client"
-  version: "0.0.1"
-  environment: "dev"
-references:
-  "UserProvider":
-    registry-ids: "demoZk"
-    protocol: "dubbo"
-    interface: "org.apache.dubbo.UserProvider"
-    cluster: "failover"
-    # this is necessary to enable direct-invoking.
-    url: "dubbo://127.0.0.1:20000"
-    methods:
-      - name: "GetUser"
-        retries: 3
-```
-
-2. Startup: Direct connection to the service to complete a service call
-
-```go
-hessian.RegisterPOJO(&pkg.User{})
-config.Load()
-user := &pkg.User{}
-err := userProvider.GetUser(context.TODO(), []interface{}{"A001"}, user)
-```
-
-
-### How To Run
-
-Refer to  [HOWTO.md](../../HOWTO_zh.md) under the root directory to run this 
sample.
-
-#### 1. Environment Configuration
-
-Configure the environment variable to specify the configuration file path 
required for the service to load.
-
-- go-server:
-
-```shell
-APP_LOG_CONF_FILE=direct/go-server/conf/log.yml;
-DUBBO_GO_CONFIG_PATH=direct/go-server/conf/server.yml
-```
-
-- go-client:
-
-```shell
-APP_LOG_CONF_FILE=direct/go-client/conf/log.yml;
-DUBBO_GO_CONFIG_PATH=direct/go-client/conf/dubbogo.yml
-```
-
-See 
[dubbo-go/.../env.go](https://dubbo.apache.org/dubbo-go/v3/blob/master/common/constant/env.go)
-
-
-#### 2. Start The Registry
-
-This example uses ZooKeeper as the registry, so you can run the Docker 
ZooKeeper environment directly. See 
[docker-compose.yml](go-server/docker/docker-compose.yml)
-
-#### 3. Start The Provider
-#### 4. Start The Consumer
-
-
-Refer to  [HOWTO.md](../../HOWTO_zh.md) under the root directory to run this 
sample.
-
diff --git a/compatibility/direct/README_zh.md 
b/compatibility/direct/README_zh.md
deleted file mode 100644
index 4733ea3e..00000000
--- a/compatibility/direct/README_zh.md
+++ /dev/null
@@ -1,171 +0,0 @@
-# Direct 示例
-
-### 背景
-
-在开发及测试环境下,经常需要绕过注册中心,测试指定服务提供者,这时候可能需要点对点直连,
-点对点直连方式,将以服务接口为单位,忽略注册中心的提供者列表,A 接口配置点对点,不影响 B 接口从注册中心获取列表。
-
-本示例提供基于 Dubbo-go 的`Consumer`点对点直连`Provider`完成服务调用,帮助更好理解 Dubbo-go 的连通性。
-
-
-### 目录
-
-```
-├── go-client     
-│   ├── cmd       启动入口
-│   ├── conf      消费者配置:dubbo 服务属性配置、日志属性配置
-│   └── pkg       业务包  
-└── go-server     
-    ├── cmd       启动入口
-    ├── conf      服务提供者配置:dubbo 服务属性配置、日志属性配置
-    ├── docker    docker compose: Zookeeper 
-    ├── pkg
-    └── tests
-        └── integration
-```
-
-- go-server: 服务提供者
-- go-client: 服务消费者
-
-#### 服务提供者
-
-直连示例代码说明:
-
-1. 配置dubbo 服务协议,注册中心,服务信息等,具体参阅 [server.yml](go-server/conf/server.yml)
-
-```yaml
-services:
-  "UserProvider":
-    registry-ids: "demoZk"
-    protocol : "dubbo"
-    interface : "org.apache.dubbo.UserProvider"
-    loadbalance: "random"
-    warmup: "100"
-    cluster: "failover"
-    methods:
-    - name: "GetUser"
-      retries: 1
-      loadbalance: "random"
-```
-
-2. 应用启动:注册服务
-
-```go
-hessian.RegisterPOJO(&pkg.User{})
-config.Load()
-initSignal()
-```
-
-- 
基于`hessian`序列化协议,使用[apache/dubbo-go-hessian2](https://github.com/apache/dubbo-go-hessian2)
 RegisterPOJO注册一个POJO实例
-- Dubbo 
Init:注册服务,详情参考[apache/dubbo-go/../config_loader.go](https://dubbo.apache.org/dubbo-go/v3/blob/master/config/config_loader.go)
-    - init router
-    - init the global event dispatcher
-    - start the metadata report if config set
-    - reference config
-    - service config
-    - init the shutdown callback
-- 初始化 signal 包:将输入信号(对应信号)转发到 `chan`, 
signal包不会为了向`chan`发送信息而阻塞,调用者应该保证`chan`有足够的缓存空间可以跟上期望的信号频率,此处单一信号用于通知的通道,缓存为设置 
`1`
-    
-    ```go
-    func initSignal() {
-        signals := make(chan os.Signal, 1)
-        // It is not possible to block SIGKILL or syscall.SIGSTOP
-        signal.Notify(signals, os.Interrup, syscall.SIGHUP, syscall.SIGQUIT, 
syscall.SIGTERM)
-        for {
-            sig := <-signals
-            logger.Infof("get signal %s", sig.String())
-            switch sig {
-            case syscall.SIGHUP:
-                // reload()
-            default:
-                time.AfterFunc(time.Duration(survivalTimeout), func() {
-                    logger.Warnf("app exit now by force...")
-                    os.Exit(1)
-                })
-    
-                // The program exits normally or timeout forcibly exits.
-                fmt.Println("provider app exit now...")
-                return
-            }
-        }
-    }
-    ```
-
-#### 服务消费者
-
-1. 在程序启动之初设置需要订阅的 `dubbo` 服务,
-   确保配置文件 `dubbogo.yml` 已配置订阅服务相关信息,可自定义设置服务属性等,覆盖 Provider 的属性配置,详情参阅 
[dubbogo.yml](go-client/conf/dubbogo.yml),
-   保留最少配置 `application` 和 `references` 验证点对点直连效果,无需注册中心等配置
-
-```go
-var userProvider = new(pkg.UserProvider)
-
-func init() {
-    config.SetConsumerService(userProvider)
-    hessian.RegisterPOJO(&pkg.User{})
-}
-```
-
-```yaml
-application:
-  organization: "dubbo.io"
-  name: "UserInfoClient"
-  module: "dubbo-go user-info client"
-  version: "0.0.1"
-  environment: "dev"
-references:
-  "UserProvider":
-    registry-ids: "demoZk"
-    protocol: "dubbo"
-    interface: "org.apache.dubbo.UserProvider"
-    cluster: "failover"
-    # this is necessary to enable direct-invoking.
-    url: "dubbo://127.0.0.1:20000"
-    methods:
-      - name: "GetUser"
-        retries: 3
-```
-
-2. 应用启动:直连服务,完成一次服务调用
-
-```go
-hessian.RegisterPOJO(&pkg.User{})
-config.Load()
-user := &pkg.User{}
-err := userProvider.GetUser(context.TODO(), []interface{}{"A001"}, user)
-```
-
-
-### 如何运行
-请参阅根目录中的 [HOWTO.md](../../HOWTO_zh.md) 来运行本例。
-#### 1. 环境配置
-
-配置环境变量,指定服务加载所需配置文件路径
-
-- go-server:
-
-```shell
-APP_LOG_CONF_FILE=direct/go-server/conf/log.yml;
-DUBBO_GO_CONFIG_PATH=direct/go-server/conf/server.yml
-```
-
-- go-client:
-
-```shell
-APP_LOG_CONF_FILE=direct/go-client/conf/log.yml;
-DUBBO_GO_CONFIG_PATH=direct/go-client/conf/dubbogo.yml
-```
-
-详情请参阅 
[dubbo-go/.../env.go](https://dubbo.apache.org/dubbo-go/v3/blob/master/common/constant/env.go)
-
-
-#### 2. 启动注册中心
-
-本示例使用 Zookeeper 做注册中心, 可以直接运行 docker zookeeper 环境,配置详情请参阅 `docker-compose.yml`
-
-#### 3. 启动服务提供者
-#### 4. 启动服务消费者
-
-
-请参阅根目录中的 [HOWTO.md](../../HOWTO_zh.md) 来运行本例。
-
diff --git a/compatibility/direct/go-client/conf/dubbogo.yml 
b/compatibility/direct/go-client/conf/dubbogo.yml
deleted file mode 100644
index 1b9a483c..00000000
--- a/compatibility/direct/go-client/conf/dubbogo.yml
+++ /dev/null
@@ -1,6 +0,0 @@
-dubbo:
-  consumer:
-    references:
-      GreeterClientImpl:
-        url: tri://localhost:20000
-        protocol: tri
\ No newline at end of file
diff --git a/compatibility/direct/go-server/conf/dubbogo.yml 
b/compatibility/direct/go-server/conf/dubbogo.yml
deleted file mode 100644
index 455b9b61..00000000
--- a/compatibility/direct/go-server/conf/dubbogo.yml
+++ /dev/null
@@ -1,9 +0,0 @@
-dubbo:
-  protocols:
-    triple:
-      name: tri
-      port: 20000
-  provider:
-    services:
-      GreeterProvider:
-        interface: "" # read interface from pb
\ No newline at end of file
diff --git a/direct/README.md b/direct/README.md
new file mode 100644
index 00000000..cb3f30c6
--- /dev/null
+++ b/direct/README.md
@@ -0,0 +1,49 @@
+# Direct Sample (Triple Direct Call)
+
+[English](README.md) | [中文](README_zh.md)
+
+This sample demonstrates how to use the Dubbo-Go v3 triple API to perform a 
point-to-point invocation without any registry. The consumer dials a target URL 
(`tri://127.0.0.1:20000`) directly, which makes it ideal for local debugging or 
traffic mirroring scenarios.
+
+## Layout
+
+```
+direct/
+├── proto/          # greet proto definition and generated triple stubs
+├── go-server/      # triple provider listening on :20000
+└── go-client/      # consumer dialing the provider directly
+```
+
+## Run the provider
+
+```bash
+cd direct/go-server/cmd
+go run .
+```
+
+The server uses the triple protocol on port `20000` and implements 
`greet.GreetService`.
+
+## Run the consumer
+
+```bash
+cd direct/go-client/cmd
+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.
+
+## Expected output
+
+Provider log:
+
+```
+INFO ... Direct server received name = dubbo-go
+```
+
+Consumer log:
+
+```
+INFO ... direct call response: hello dubbo-go
+```
+
+That's it—this sample shows the minimal code you need to stand up a direct 
triple connection with Dubbo-Go.
+
diff --git a/direct/README_zh.md b/direct/README_zh.md
new file mode 100644
index 00000000..7aff5430
--- /dev/null
+++ b/direct/README_zh.md
@@ -0,0 +1,94 @@
+# Direct 示例(Triple 直连)
+
+[English](README.md) | [中文](README_zh.md)
+
+在本示例中,Dubbo-Go v3 Triple 服务端直接监听本地端口,客户端通过 
`client.WithClientURL("tri://127.0.0.1:20000")` 
指定目标地址,完全绕过注册中心,展示最小可运行的点对点调用链路,方便本地调试。
+
+## 目录结构
+
+```
+direct/
+├── proto/          # greet.proto 以及对应的 triple 代码
+├── go-server/      # 提供 greet.GreetService 的服务端
+└── go-client/      # 直接拨号 tri://127.0.0.1:20000 的客户端
+```
+
+## 启动服务端
+
+```bash
+cd direct/go-server/cmd
+go run .
+```
+
+服务端监听 `20000` 端口,并实现 `greet.GreetService` 的 `Greet` 方法。
+
+## 启动客户端
+
+```bash
+cd direct/go-client/cmd
+go run .
+```
+
+客户端通过 `client.WithClientURL` 配置直连地址,无需任何 yaml 配置,也无需注册中心即可完成调用。
+
+## 预期输出
+
+服务端日志:
+
+```
+INFO ... Direct server received name = dubbo-go
+```
+
+客户端日志:
+
+```
+INFO ... direct call response: hello dubbo-go
+```
+
+以上就是使用 Dubbo-Go 实现 Triple 直连的全部步骤。
+# Direct 示例(Triple 直连)
+
+在本示例中,Dubbo-Go v3 Triple 服务端直接监听本地端口,客户端通过 
`client.WithClientURL("tri://127.0.0.1:20000")` 
指定目标地址,完全绕过注册中心,展示最小可运行的点对点调用链路,方便本地调试。
+
+## 目录结构
+
+```
+direct/
+├── proto/          # greet.proto 以及对应的 triple 代码
+├── go-server/      # 提供 greet.GreetService 的服务端
+└── go-client/      # 直接拨号 tri://127.0.0.1:20000 的客户端
+```
+
+## 启动服务端
+
+```bash
+go run go-server/cmd/main.go
+```
+
+服务端监听 `20000` 端口,并实现 `greet.GreetService` 的 `Greet` 方法。
+
+## 启动客户端
+
+```bash
+go run go-client/cmd/main.go
+```
+
+客户端通过 `client.WithClientURL` 配置直连地址,无需任何 yaml 配置,也无需注册中心即可完成调用。
+
+## 预期输出
+
+服务端日志:
+
+```
+INFO ... Direct server received name = dubbo-go
+```
+
+客户端日志:
+
+```
+INFO ... direct call response: hello dubbo-go
+```
+
+以上就是使用 Dubbo-Go 实现 Triple 直连的全部步骤。
+
+
diff --git a/compatibility/direct/go-client/cmd/client.go 
b/direct/go-client/cmd/main.go
similarity index 65%
rename from compatibility/direct/go-client/cmd/client.go
rename to direct/go-client/cmd/main.go
index a4ca1768..bdaf8dae 100644
--- a/compatibility/direct/go-client/cmd/client.go
+++ b/direct/go-client/cmd/main.go
@@ -22,32 +22,34 @@ import (
 )
 
 import (
-       "dubbo.apache.org/dubbo-go/v3/config"
+       "dubbo.apache.org/dubbo-go/v3/client"
        _ "dubbo.apache.org/dubbo-go/v3/imports"
 
        "github.com/dubbogo/gost/log/logger"
 )
 
 import (
-       "github.com/apache/dubbo-go-samples/compatibility/api"
+       greet "github.com/apache/dubbo-go-samples/direct/proto"
 )
 
-var grpcGreeterImpl = new(api.GreeterClientImpl)
-
-// export DUBBO_GO_CONFIG_PATH= 
PATH_TO_SAMPLES/direct/go-client/conf/dubbogo.yml
 func main() {
-       config.SetConsumerService(grpcGreeterImpl)
-       if err := config.Load(); err != nil {
+       cli, err := client.NewClient(
+               client.WithClientURL("tri://127.0.0.1:20000"),
+       )
+       if err != nil {
                panic(err)
        }
 
-       logger.Info("start to test dubbo")
-       req := &api.HelloRequest{
-               Name: "laurence",
+       greetService, err := greet.NewGreetService(cli)
+       if err != nil {
+               panic(err)
        }
-       reply, err := grpcGreeterImpl.SayHello(context.Background(), req)
+
+       req := &greet.GreetRequest{Name: "dubbo-go"}
+       resp, err := greetService.Greet(context.Background(), req)
        if err != nil {
-               logger.Error(err)
+               logger.Errorf("direct call failed: %v", err)
+               return
        }
-       logger.Infof("client response result: %v\n", reply)
+       logger.Infof("direct call response: %s", resp.Greeting)
 }
diff --git a/compatibility/direct/go-server/cmd/server.go 
b/direct/go-server/cmd/main.go
similarity index 57%
rename from compatibility/direct/go-server/cmd/server.go
rename to direct/go-server/cmd/main.go
index 1c6127f7..10375cfb 100644
--- a/compatibility/direct/go-server/cmd/server.go
+++ b/direct/go-server/cmd/main.go
@@ -22,30 +22,40 @@ import (
 )
 
 import (
-       "dubbo.apache.org/dubbo-go/v3/config"
        _ "dubbo.apache.org/dubbo-go/v3/imports"
+       "dubbo.apache.org/dubbo-go/v3/protocol"
+       "dubbo.apache.org/dubbo-go/v3/server"
 
        "github.com/dubbogo/gost/log/logger"
 )
 
 import (
-       "github.com/apache/dubbo-go-samples/compatibility/api"
+       greet "github.com/apache/dubbo-go-samples/direct/proto"
 )
 
-type GreeterProvider struct {
-       api.UnimplementedGreeterServer
-}
+type DirectGreetServer struct{}
 
-func (s *GreeterProvider) SayHello(ctx context.Context, in *api.HelloRequest) 
(*api.User, error) {
-       logger.Infof("Dubbo3 GreeterProvider get user name = %s\n", in.Name)
-       return &api.User{Name: "Hello " + in.Name, Id: "12345", Age: 21}, nil
+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
 }
 
-// export DUBBO_GO_CONFIG_PATH= 
PATH_TO_SAMPLES/direct/go-server/conf/dubbogo.yml
 func main() {
-       config.SetProviderService(&GreeterProvider{})
-       if err := config.Load(); err != nil {
+       srv, err := server.NewServer(
+               server.WithServerProtocol(
+                       protocol.WithTriple(),
+                       protocol.WithPort(20000),
+               ),
+       )
+       if err != nil {
+               panic(err)
+       }
+
+       if err := greet.RegisterGreetServiceHandler(srv, &DirectGreetServer{}); 
err != nil {
                panic(err)
        }
-       select {}
+
+       if err := srv.Serve(); err != nil {
+               logger.Errorf("direct server stopped: %v", err)
+       }
 }
diff --git a/direct/proto/greet.pb.go b/direct/proto/greet.pb.go
new file mode 100644
index 00000000..50d72925
--- /dev/null
+++ b/direct/proto/greet.pb.go
@@ -0,0 +1,230 @@
+//
+// 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.
+
+// Code generated by protoc-gen-go. DO NOT EDIT.
+// versions:
+//     protoc-gen-go v1.31.0
+//     protoc        v3.21.12
+// source: proto/greet.proto
+
+package greet
+
+import (
+       protoreflect "google.golang.org/protobuf/reflect/protoreflect"
+       protoimpl "google.golang.org/protobuf/runtime/protoimpl"
+       reflect "reflect"
+       sync "sync"
+)
+
+const (
+       // Verify that this generated code is sufficiently up-to-date.
+       _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
+       // Verify that runtime/protoimpl is sufficiently up-to-date.
+       _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
+)
+
+type GreetRequest struct {
+       state         protoimpl.MessageState
+       sizeCache     protoimpl.SizeCache
+       unknownFields protoimpl.UnknownFields
+
+       Name string `protobuf:"bytes,1,opt,name=name,proto3" 
json:"name,omitempty"`
+}
+
+func (x *GreetRequest) Reset() {
+       *x = GreetRequest{}
+       if protoimpl.UnsafeEnabled {
+               mi := &file_proto_greet_proto_msgTypes[0]
+               ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+               ms.StoreMessageInfo(mi)
+       }
+}
+
+func (x *GreetRequest) String() string {
+       return protoimpl.X.MessageStringOf(x)
+}
+
+func (*GreetRequest) ProtoMessage() {}
+
+func (x *GreetRequest) ProtoReflect() protoreflect.Message {
+       mi := &file_proto_greet_proto_msgTypes[0]
+       if protoimpl.UnsafeEnabled && x != nil {
+               ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+               if ms.LoadMessageInfo() == nil {
+                       ms.StoreMessageInfo(mi)
+               }
+               return ms
+       }
+       return mi.MessageOf(x)
+}
+
+// Deprecated: Use GreetRequest.ProtoReflect.Descriptor instead.
+func (*GreetRequest) Descriptor() ([]byte, []int) {
+       return file_proto_greet_proto_rawDescGZIP(), []int{0}
+}
+
+func (x *GreetRequest) GetName() string {
+       if x != nil {
+               return x.Name
+       }
+       return ""
+}
+
+type GreetResponse struct {
+       state         protoimpl.MessageState
+       sizeCache     protoimpl.SizeCache
+       unknownFields protoimpl.UnknownFields
+
+       Greeting string `protobuf:"bytes,1,opt,name=greeting,proto3" 
json:"greeting,omitempty"`
+}
+
+func (x *GreetResponse) Reset() {
+       *x = GreetResponse{}
+       if protoimpl.UnsafeEnabled {
+               mi := &file_proto_greet_proto_msgTypes[1]
+               ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+               ms.StoreMessageInfo(mi)
+       }
+}
+
+func (x *GreetResponse) String() string {
+       return protoimpl.X.MessageStringOf(x)
+}
+
+func (*GreetResponse) ProtoMessage() {}
+
+func (x *GreetResponse) ProtoReflect() protoreflect.Message {
+       mi := &file_proto_greet_proto_msgTypes[1]
+       if protoimpl.UnsafeEnabled && x != nil {
+               ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+               if ms.LoadMessageInfo() == nil {
+                       ms.StoreMessageInfo(mi)
+               }
+               return ms
+       }
+       return mi.MessageOf(x)
+}
+
+// Deprecated: Use GreetResponse.ProtoReflect.Descriptor instead.
+func (*GreetResponse) Descriptor() ([]byte, []int) {
+       return file_proto_greet_proto_rawDescGZIP(), []int{1}
+}
+
+func (x *GreetResponse) GetGreeting() string {
+       if x != nil {
+               return x.Greeting
+       }
+       return ""
+}
+
+var File_proto_greet_proto protoreflect.FileDescriptor
+
+var file_proto_greet_proto_rawDesc = []byte{
+       0x0a, 0x11, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x72, 0x65, 0x65, 
0x74, 0x2e, 0x70, 0x72,
+       0x6f, 0x74, 0x6f, 0x12, 0x05, 0x67, 0x72, 0x65, 0x65, 0x74, 0x22, 0x22, 
0x0a, 0x0c, 0x47, 0x72,
+       0x65, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 
0x0a, 0x04, 0x6e, 0x61,
+       0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 
0x6d, 0x65, 0x22, 0x2b,
+       0x0a, 0x0d, 0x47, 0x72, 0x65, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 
0x6e, 0x73, 0x65, 0x12,
+       0x1a, 0x0a, 0x08, 0x67, 0x72, 0x65, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x18, 
0x01, 0x20, 0x01, 0x28,
+       0x09, 0x52, 0x08, 0x67, 0x72, 0x65, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x32, 
0x44, 0x0a, 0x0c, 0x47,
+       0x72, 0x65, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 
0x34, 0x0a, 0x05, 0x47,
+       0x72, 0x65, 0x65, 0x74, 0x12, 0x13, 0x2e, 0x67, 0x72, 0x65, 0x65, 0x74, 
0x2e, 0x47, 0x72, 0x65,
+       0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 
0x67, 0x72, 0x65, 0x65,
+       0x74, 0x2e, 0x47, 0x72, 0x65, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 
0x6e, 0x73, 0x65, 0x22,
+       0x00, 0x42, 0x37, 0x5a, 0x35, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 
0x63, 0x6f, 0x6d, 0x2f,
+       0x61, 0x70, 0x61, 0x63, 0x68, 0x65, 0x2f, 0x64, 0x75, 0x62, 0x62, 0x6f, 
0x2d, 0x67, 0x6f, 0x2d,
+       0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x64, 0x69, 0x72, 0x65, 
0x63, 0x74, 0x2f, 0x70,
+       0x72, 0x6f, 0x74, 0x6f, 0x3b, 0x67, 0x72, 0x65, 0x65, 0x74, 0x62, 0x06, 
0x70, 0x72, 0x6f, 0x74,
+       0x6f, 0x33,
+}
+
+var (
+       file_proto_greet_proto_rawDescOnce sync.Once
+       file_proto_greet_proto_rawDescData = file_proto_greet_proto_rawDesc
+)
+
+func file_proto_greet_proto_rawDescGZIP() []byte {
+       file_proto_greet_proto_rawDescOnce.Do(func() {
+               file_proto_greet_proto_rawDescData = 
protoimpl.X.CompressGZIP(file_proto_greet_proto_rawDescData)
+       })
+       return file_proto_greet_proto_rawDescData
+}
+
+var file_proto_greet_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
+var file_proto_greet_proto_goTypes = []interface{}{
+       (*GreetRequest)(nil),  // 0: greet.GreetRequest
+       (*GreetResponse)(nil), // 1: greet.GreetResponse
+}
+var file_proto_greet_proto_depIdxs = []int32{
+       0, // 0: greet.GreetService.Greet:input_type -> greet.GreetRequest
+       1, // 1: greet.GreetService.Greet:output_type -> greet.GreetResponse
+       1, // [1:2] is the sub-list for method output_type
+       0, // [0:1] is the sub-list for method input_type
+       0, // [0:0] is the sub-list for extension type_name
+       0, // [0:0] is the sub-list for extension extendee
+       0, // [0:0] is the sub-list for field type_name
+}
+
+func init() { file_proto_greet_proto_init() }
+func file_proto_greet_proto_init() {
+       if File_proto_greet_proto != nil {
+               return
+       }
+       if !protoimpl.UnsafeEnabled {
+               file_proto_greet_proto_msgTypes[0].Exporter = func(v 
interface{}, i int) interface{} {
+                       switch v := v.(*GreetRequest); i {
+                       case 0:
+                               return &v.state
+                       case 1:
+                               return &v.sizeCache
+                       case 2:
+                               return &v.unknownFields
+                       default:
+                               return nil
+                       }
+               }
+               file_proto_greet_proto_msgTypes[1].Exporter = func(v 
interface{}, i int) interface{} {
+                       switch v := v.(*GreetResponse); i {
+                       case 0:
+                               return &v.state
+                       case 1:
+                               return &v.sizeCache
+                       case 2:
+                               return &v.unknownFields
+                       default:
+                               return nil
+                       }
+               }
+       }
+       type x struct{}
+       out := protoimpl.TypeBuilder{
+               File: protoimpl.DescBuilder{
+                       GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
+                       RawDescriptor: file_proto_greet_proto_rawDesc,
+                       NumEnums:      0,
+                       NumMessages:   2,
+                       NumExtensions: 0,
+                       NumServices:   1,
+               },
+               GoTypes:           file_proto_greet_proto_goTypes,
+               DependencyIndexes: file_proto_greet_proto_depIdxs,
+               MessageInfos:      file_proto_greet_proto_msgTypes,
+       }.Build()
+       File_proto_greet_proto = out.File
+       file_proto_greet_proto_rawDesc = nil
+       file_proto_greet_proto_goTypes = nil
+       file_proto_greet_proto_depIdxs = nil
+}
diff --git a/integrate_test/compatibility/direct/tests/integration/main_test.go 
b/direct/proto/greet.proto
similarity index 65%
copy from integrate_test/compatibility/direct/tests/integration/main_test.go
copy to direct/proto/greet.proto
index 4f81a75d..641d7375 100644
--- a/integrate_test/compatibility/direct/tests/integration/main_test.go
+++ b/direct/proto/greet.proto
@@ -15,30 +15,20 @@
  * limitations under the License.
  */
 
-package integration
+syntax = "proto3";
 
-import (
-       "os"
-       "testing"
-)
+package greet;
 
-import (
-       "dubbo.apache.org/dubbo-go/v3/config"
-       _ "dubbo.apache.org/dubbo-go/v3/imports"
-)
+option go_package = "github.com/apache/dubbo-go-samples/direct/proto;greet";
 
-import (
-       dubbo3pb "github.com/apache/dubbo-go-samples/compatibility/api"
-)
-
-var greeterProvider = new(dubbo3pb.GreeterClientImpl)
-
-func TestMain(m *testing.M) {
-       config.SetConsumerService(greeterProvider)
-       err := config.Load()
-       if err != nil {
-               panic(err)
-       }
+message GreetRequest {
+  string name = 1;
+}
 
-       os.Exit(m.Run())
+message GreetResponse {
+  string greeting = 1;
 }
+
+service GreetService {
+  rpc Greet(GreetRequest) returns (GreetResponse) {}
+}
\ No newline at end of file
diff --git a/direct/proto/greet.triple.go b/direct/proto/greet.triple.go
new file mode 100644
index 00000000..1df73466
--- /dev/null
+++ b/direct/proto/greet.triple.go
@@ -0,0 +1,122 @@
+// Code generated by protoc-gen-triple. DO NOT EDIT.
+//
+// Source: proto/greet.proto
+package greet
+
+import (
+       "context"
+)
+
+import (
+       "dubbo.apache.org/dubbo-go/v3"
+       "dubbo.apache.org/dubbo-go/v3/client"
+       "dubbo.apache.org/dubbo-go/v3/common"
+       "dubbo.apache.org/dubbo-go/v3/common/constant"
+       "dubbo.apache.org/dubbo-go/v3/protocol/triple/triple_protocol"
+       "dubbo.apache.org/dubbo-go/v3/server"
+)
+
+// This is a compile-time assertion to ensure that this generated file and the 
Triple package
+// are compatible. If you get a compiler error that this constant is not 
defined, this code was
+// generated with a version of Triple newer than the one compiled into your 
binary. You can fix the
+// problem by either regenerating this code with an older version of Triple or 
updating the Triple
+// version compiled into your binary.
+const _ = triple_protocol.IsAtLeastVersion0_1_0
+
+const (
+       // GreetServiceName is the fully-qualified name of the GreetService 
service.
+       GreetServiceName = "greet.GreetService"
+)
+
+// These constants are the fully-qualified names of the RPCs defined in this 
package. They're
+// exposed at runtime as procedure and as the final two segments of the HTTP 
route.
+//
+// Note that these are different from the fully-qualified method names used by
+// google.golang.org/protobuf/reflect/protoreflect. To convert from these 
constants to
+// reflection-formatted method names, remove the leading slash and convert the 
remaining slash to a
+// period.
+const (
+       // GreetServiceGreetProcedure is the fully-qualified name of the 
GreetService's Greet RPC.
+       GreetServiceGreetProcedure = "/greet.GreetService/Greet"
+)
+
+var (
+       _ GreetService = (*GreetServiceImpl)(nil)
+)
+
+// GreetService is a client for the greet.GreetService service.
+type GreetService interface {
+       Greet(ctx context.Context, req *GreetRequest, opts 
...client.CallOption) (*GreetResponse, error)
+}
+
+// NewGreetService constructs a client for the greet.GreetService service.
+func NewGreetService(cli *client.Client, opts ...client.ReferenceOption) 
(GreetService, error) {
+       conn, err := cli.DialWithInfo("greet.GreetService", 
&GreetService_ClientInfo, opts...)
+       if err != nil {
+               return nil, err
+       }
+       return &GreetServiceImpl{
+               conn: conn,
+       }, nil
+}
+
+func SetConsumerGreetService(srv common.RPCService) {
+       dubbo.SetConsumerServiceWithInfo(srv, &GreetService_ClientInfo)
+}
+
+// GreetServiceImpl implements GreetService.
+type GreetServiceImpl struct {
+       conn *client.Connection
+}
+
+func (c *GreetServiceImpl) Greet(ctx context.Context, req *GreetRequest, opts 
...client.CallOption) (*GreetResponse, error) {
+       resp := new(GreetResponse)
+       if err := c.conn.CallUnary(ctx, []interface{}{req}, resp, "Greet", 
opts...); err != nil {
+               return nil, err
+       }
+       return resp, nil
+}
+
+var GreetService_ClientInfo = client.ClientInfo{
+       InterfaceName: "greet.GreetService",
+       MethodNames:   []string{"Greet"},
+       ConnectionInjectFunc: func(dubboCliRaw interface{}, conn 
*client.Connection) {
+               dubboCli := dubboCliRaw.(*GreetServiceImpl)
+               dubboCli.conn = conn
+       },
+}
+
+// GreetServiceHandler is an implementation of the greet.GreetService service.
+type GreetServiceHandler interface {
+       Greet(context.Context, *GreetRequest) (*GreetResponse, error)
+}
+
+func RegisterGreetServiceHandler(srv *server.Server, hdlr GreetServiceHandler, 
opts ...server.ServiceOption) error {
+       return srv.Register(hdlr, &GreetService_ServiceInfo, opts...)
+}
+
+func SetProviderGreetService(srv common.RPCService) {
+       dubbo.SetProviderServiceWithInfo(srv, &GreetService_ServiceInfo)
+}
+
+var GreetService_ServiceInfo = server.ServiceInfo{
+       InterfaceName: "greet.GreetService",
+       ServiceType:   (*GreetServiceHandler)(nil),
+       Methods: []server.MethodInfo{
+               {
+                       Name: "Greet",
+                       Type: constant.CallUnary,
+                       ReqInitFunc: func() interface{} {
+                               return new(GreetRequest)
+                       },
+                       MethodFunc: func(ctx context.Context, args 
[]interface{}, handler interface{}) (interface{}, error) {
+                               req := args[0].(*GreetRequest)
+                               res, err := 
handler.(GreetServiceHandler).Greet(ctx, req)
+                               if err != nil {
+                                       return nil, err
+                               }
+                               return triple_protocol.NewResponse(res), nil
+                       },
+               },
+       },
+}
diff --git a/integrate_test/compatibility/direct/tests/integration/main_test.go 
b/integrate_test/direct/tests/integration/main_test.go
similarity index 73%
rename from integrate_test/compatibility/direct/tests/integration/main_test.go
rename to integrate_test/direct/tests/integration/main_test.go
index 4f81a75d..6ba14250 100644
--- a/integrate_test/compatibility/direct/tests/integration/main_test.go
+++ b/integrate_test/direct/tests/integration/main_test.go
@@ -23,19 +23,27 @@ import (
 )
 
 import (
-       "dubbo.apache.org/dubbo-go/v3/config"
+       "dubbo.apache.org/dubbo-go/v3/client"
        _ "dubbo.apache.org/dubbo-go/v3/imports"
 )
 
 import (
-       dubbo3pb "github.com/apache/dubbo-go-samples/compatibility/api"
+       greet "github.com/apache/dubbo-go-samples/direct/proto"
 )
 
-var greeterProvider = new(dubbo3pb.GreeterClientImpl)
+var greetService greet.GreetService
 
 func TestMain(m *testing.M) {
-       config.SetConsumerService(greeterProvider)
-       err := config.Load()
+       cli, err := client.NewClient(
+               client.WithClientURL("tri://127.0.0.1:20000"),
+               client.WithClientClusterFailFast(),
+               client.WithClientRetries(0),
+       )
+       if err != nil {
+               panic(err)
+       }
+
+       greetService, err = greet.NewGreetService(cli)
        if err != nil {
                panic(err)
        }
diff --git 
a/integrate_test/compatibility/direct/tests/integration/userprovider_test.go 
b/integrate_test/direct/tests/integration/userprovider_test.go
similarity index 72%
rename from 
integrate_test/compatibility/direct/tests/integration/userprovider_test.go
rename to integrate_test/direct/tests/integration/userprovider_test.go
index d86c1c52..7affecea 100644
--- a/integrate_test/compatibility/direct/tests/integration/userprovider_test.go
+++ b/integrate_test/direct/tests/integration/userprovider_test.go
@@ -27,20 +27,16 @@ import (
 )
 
 import (
-       dubbo3pb "github.com/apache/dubbo-go-samples/compatibility/api"
+       greet "github.com/apache/dubbo-go-samples/direct/proto"
 )
 
-func TestSayHello(t *testing.T) {
-       req := &dubbo3pb.HelloRequest{
-               Name: "laurence",
+func TestGreet(t *testing.T) {
+       req := &greet.GreetRequest{
+               Name: "integration",
        }
 
-       ctx := context.Background()
-
-       reply, err := greeterProvider.SayHello(ctx, req)
+       resp, err := greetService.Greet(context.Background(), req)
 
        assert.Nil(t, err)
-       assert.Equal(t, "Hello laurence", reply.Name)
-       assert.Equal(t, "12345", reply.Id)
-       assert.Equal(t, int32(21), reply.Age)
+       assert.Equal(t, "hello integration", resp.Greeting)
 }
diff --git a/start_integrate_test.sh b/start_integrate_test.sh
index fc254dcf..de33b4e6 100755
--- a/start_integrate_test.sh
+++ b/start_integrate_test.sh
@@ -33,7 +33,7 @@ array+=("otel/tracing/stdout")
 array+=("otel/tracing/otlp_http_exporter")
 
 # direct
-array+=("compatibility/direct")
+array+=("direct")
 
 # filer
 array+=("filter/token")


Reply via email to