Add config_yaml samples
Signed-off-by: YarBor <yarbor.ww@gmail.com>
diff --git a/config_yaml/README.md b/config_yaml/README.md
new file mode 100644
index 0000000..5a44b2c
--- /dev/null
+++ b/config_yaml/README.md
@@ -0,0 +1,232 @@
+# Dubbo-go Config_Yaml
+
+## 1.Introduction
+
+This example demonstrates how to configure using yaml configuration files in Dubbo-go framework
+
+## 2.Run
+```txt
+.
+├── go-client
+│ ├── cmd
+│ │ └── main.go
+│ └── conf
+│ └── dubbogo.yml
+├── go-server
+│ ├── cmd
+│ │ └── main.go
+│ └── conf
+│ └── dubbogo.yml
+└─── proto
+ ├── greet.pb.go
+ ├── greet.proto
+ └── greet.triple.go
+
+```
+通过 IDL`./proto/greet.proto` 定义服务 使用triple协议
+
+### build Proto
+```bash
+cd path_to_dubbogo-sample/config_yaml/proto
+protoc --go_out=. --go-triple_out=. ./greet.proto
+```
+### Server
+```bash
+export DUBBO_GO_CONFIG_PATH="../conf/dubbogo.yml"
+cd path_to_dubbogo-sample/config_yaml/go-server/cmd
+go run .
+```
+### Client
+```bash
+export DUBBO_GO_CONFIG_PATH="../conf/dubbogo.yml"
+cd path_to_dubbogo-sample/config_yaml/go-client/cmd
+go run .
+```
+
+### 2.1 Client usage instructions
+
+Client-defined yaml file
+```yaml
+# dubbo client yaml configure file
+dubbo:
+ registries:
+ demoZK:
+ protocol: zookeeper
+ timeout: 3s
+ address: 127.0.0.1:2181
+ consumer:
+ references:
+ GreetServiceImpl:
+ protocol: tri
+ interface: com.apache.dubbo.sample.Greeter
+ registry: demoZK
+ retries: 3
+ timeout: 3000
+```
+Read and load files through dubbo.Load() calls
+
+```go
+//...
+func main() {
+ //...
+ if err := dubbo.Load(); err != nil {
+ //...
+ }
+ //...
+}
+```
+
+### 2.2 Server usage instructions
+
+Yaml file defined on the server side
+
+```yaml
+# dubbo server yaml configure file
+dubbo:
+ registries:
+ demoZK:
+ protocol: zookeeper
+ timeout: 10s
+ address: 127.0.0.1:2181
+ protocols:
+ tripleProtocol:
+ name: tri
+ port: 20000
+ provider:
+ services:
+ GreetTripleServer:
+ interface: com.apache.dubbo.sample.Greeter
+```
+
+Read and load files through dubbo.Load() calls
+```go
+//...
+func main() {
+ //...
+ if err := dubbo.Load(); err != nil {
+ //...
+ }
+ //...
+}
+```
+## 3.Example
+
+### 3.1 Server
+
+#### IDL
+
+Source file path :dubbo-go-sample/context/proto/greet.proto
+
+```protobuf
+syntax = "proto3";
+
+package greet;
+
+option go_package = "github.com/apache/dubbo-go-samples/config_yaml/proto;greet";
+
+message GreetRequest {
+ string name = 1;
+}
+
+message GreetResponse {
+ string greeting = 1;
+}
+
+service GreetService {
+ rpc Greet(GreetRequest) returns (GreetResponse) {}
+}
+```
+
+#### Server Handler
+
+On the server side, define GreetTripleServer interface:
+```go
+type GreetServiceHandler interface {
+ Greet(context.Context, *GreetRequest) (*GreetResponse, error)
+}
+```
+Implement the GreetServiceHandler interface and register through `greet.SetProviderService(&GreetTripleServer{})`
+Also use `dubbo.Load()` to load the configuration file
+
+Source file path :dubbo-go-sample/config_yaml/go-server/cmd/main.go
+
+```go
+
+package main
+
+import (
+ "context"
+ "dubbo.apache.org/dubbo-go/v3"
+ _ "dubbo.apache.org/dubbo-go/v3/imports"
+ "errors"
+ "fmt"
+
+ greet "github.com/apache/dubbo-go-samples/config_yaml/proto"
+)
+
+type GreetTripleServer struct {
+}
+
+func (srv *GreetTripleServer) Greet(ctx context.Context, req *greet.GreetRequest) (*greet.GreetResponse, error) {
+ name := req.Name
+ if name != "ConfigTest" {
+ errInfo := fmt.Sprintf("name is not right: %s", name)
+ return nil, errors.New(errInfo)
+ }
+
+ resp := &greet.GreetResponse{Greeting: req.Name + "-Success"}
+ return resp, nil
+}
+
+func main() {
+ greet.SetProviderService(&GreetTripleServer{})
+ if err := dubbo.Load(); err != nil {
+ panic(err)
+ }
+ select {}
+}
+```
+
+### 3.2 Client
+
+In the client, define greet.GreetServiceImpl instance and register with greet.SetConsumerService(svc):
+Load the configuration file through `dubbo.Load()`
+
+Source file path :dubbo-go-sample/config_yaml/go-client/cmd/main.go
+
+```go
+package main
+
+import (
+ "context"
+ "dubbo.apache.org/dubbo-go/v3"
+ _ "dubbo.apache.org/dubbo-go/v3/imports"
+ greet "github.com/apache/dubbo-go-samples/config_yaml/proto"
+ "github.com/dubbogo/gost/log/logger"
+)
+
+var svc = new(greet.GreetServiceImpl)
+
+func main() {
+ greet.SetConsumerService(svc)
+ if err := dubbo.Load(); err != nil {
+ panic(err)
+ }
+ req, err := svc.Greet(context.Background(), &greet.GreetRequest{Name: "ConfigTest"})
+ if err != nil || req.Greeting != "ConfigTest-Success" {
+ panic(err)
+ }
+ logger.Info("ConfigTest successfully")
+}
+
+```
+
+### 3.3 Show
+
+Start the server first and then the client. You can observe that the client prints `ConfigTest successfully` and the configuration is loaded and the call is successful.
+
+```
+2024-03-11 15:47:29 INFO cmd/main.go:39 ConfigTest successfully
+```
+
+
diff --git a/config_yaml/README_zh.md b/config_yaml/README_zh.md
new file mode 100644
index 0000000..f1c2caf
--- /dev/null
+++ b/config_yaml/README_zh.md
@@ -0,0 +1,233 @@
+# Dubbo-go Config_Yaml
+
+## 1.介绍
+
+本示例演示如何在Dubbo-go框架中使用yaml配置文件进行配置
+
+## 2.使用说明
+```txt
+.
+├── go-client
+│ ├── cmd
+│ │ └── main.go
+│ └── conf
+│ └── dubbogo.yml
+├── go-server
+│ ├── cmd
+│ │ └── main.go
+│ └── conf
+│ └── dubbogo.yml
+└─── proto
+ ├── greet.pb.go
+ ├── greet.proto
+ └── greet.triple.go
+
+```
+通过 IDL`./proto/greet.proto` 定义服务 使用triple协议
+
+
+### build Proto
+```bash
+cd path_to_dubbogo-sample/config_yaml/proto
+protoc --go_out=. --go-triple_out=. ./greet.proto
+```
+### Server
+```bash
+export DUBBO_GO_CONFIG_PATH="../conf/dubbogo.yml"
+cd path_to_dubbogo-sample/config_yaml/go-server/cmd
+go run .
+```
+### Client
+```bash
+export DUBBO_GO_CONFIG_PATH="../conf/dubbogo.yml"
+cd path_to_dubbogo-sample/config_yaml/go-client/cmd
+go run .
+```
+
+### 2.1客户端使用说明
+
+客户端定义的yaml文件
+```yaml
+# dubbo client yaml configure file
+dubbo:
+ registries:
+ demoZK:
+ protocol: zookeeper
+ timeout: 3s
+ address: 127.0.0.1:2181
+ consumer:
+ references:
+ GreetServiceImpl:
+ protocol: tri
+ interface: com.apache.dubbo.sample.Greeter
+ registry: demoZK
+ retries: 3
+ timeout: 3000
+```
+通过dubbo.Load()调用进行文件的读取以及加载
+```go
+//...
+func main() {
+ //...
+ if err := dubbo.Load(); err != nil {
+ //...
+ }
+ //...
+}
+```
+
+### 2.2服务端使用说明
+
+服务端定义的yaml文件
+```yaml
+# dubbo server yaml configure file
+dubbo:
+ registries:
+ demoZK:
+ protocol: zookeeper
+ timeout: 10s
+ address: 127.0.0.1:2181
+ protocols:
+ tripleProtocol:
+ name: tri
+ port: 20000
+ provider:
+ services:
+ GreetTripleServer:
+ interface: com.apache.dubbo.sample.Greeter
+```
+通过dubbo.Load()调用进行文件的读取以及加载
+```go
+//...
+func main() {
+ //...
+ if err := dubbo.Load(); err != nil {
+ //...
+ }
+ //...
+}
+
+```
+## 3.案例
+
+### 3.1服务端介绍
+
+#### 服务端proto文件
+
+源文件路径:dubbo-go-sample/context/proto/greet.proto
+
+```protobuf
+syntax = "proto3";
+
+package greet;
+
+option go_package = "github.com/apache/dubbo-go-samples/config_yaml/proto;greet";
+
+message GreetRequest {
+ string name = 1;
+}
+
+message GreetResponse {
+ string greeting = 1;
+}
+
+service GreetService {
+ rpc Greet(GreetRequest) returns (GreetResponse) {}
+}
+```
+
+#### 服务端handler文件
+
+在服务端中,定义GreetTripleServer:
+```go
+type GreetServiceHandler interface {
+ Greet(context.Context, *GreetRequest) (*GreetResponse, error)
+}
+```
+实现GreetServiceHandler接口,通过`greet.SetProviderService(&GreetTripleServer{})`进行注册
+同样使用`dubbo.Load()`进行加载配置文件
+
+
+源文件路径:dubbo-go-sample/config_yaml/go-server/cmd/main.go
+
+```go
+
+package main
+
+import (
+ "context"
+ "dubbo.apache.org/dubbo-go/v3"
+ _ "dubbo.apache.org/dubbo-go/v3/imports"
+ "errors"
+ "fmt"
+
+ greet "github.com/apache/dubbo-go-samples/config_yaml/proto"
+)
+
+type GreetTripleServer struct {
+}
+
+func (srv *GreetTripleServer) Greet(ctx context.Context, req *greet.GreetRequest) (*greet.GreetResponse, error) {
+ name := req.Name
+ if name != "ConfigTest" {
+ errInfo := fmt.Sprintf("name is not right: %s", name)
+ return nil, errors.New(errInfo)
+ }
+
+ resp := &greet.GreetResponse{Greeting: req.Name + "-Success"}
+ return resp, nil
+}
+
+func main() {
+ greet.SetProviderService(&GreetTripleServer{})
+ if err := dubbo.Load(); err != nil {
+ panic(err)
+ }
+ select {}
+}
+```
+
+### 3.2客户端介绍
+
+在客户端中,定义greet.GreetServiceImpl实例,greet.SetConsumerService(svc)进行注册:
+通过 `dubbo.Load()` 进行配置文件的加载
+
+源文件路径:dubbo-go-sample/config_yaml/go-client/cmd/main.go
+
+```go
+package main
+
+import (
+ "context"
+ "dubbo.apache.org/dubbo-go/v3"
+ _ "dubbo.apache.org/dubbo-go/v3/imports"
+ greet "github.com/apache/dubbo-go-samples/config_yaml/proto"
+ "github.com/dubbogo/gost/log/logger"
+)
+
+var svc = new(greet.GreetServiceImpl)
+
+func main() {
+ greet.SetConsumerService(svc)
+ if err := dubbo.Load(); err != nil {
+ panic(err)
+ }
+ req, err := svc.Greet(context.Background(), &greet.GreetRequest{Name: "ConfigTest"})
+ if err != nil || req.Greeting != "ConfigTest-Success" {
+ panic(err)
+ }
+ logger.Info("ConfigTest successfully")
+}
+
+```
+
+### 3.3案例效果
+
+先启动服务端,再启动客户端,可以观察到客户端打印了`ConfigTest successfully`配置加载以及调用成功
+
+```
+2024-03-11 15:47:29 INFO cmd/main.go:39 ConfigTest successfully
+
+```
+
+
\ No newline at end of file
diff --git a/config_yaml/go-client/cmd/main.go b/config_yaml/go-client/cmd/main.go
new file mode 100644
index 0000000..67a0018
--- /dev/null
+++ b/config_yaml/go-client/cmd/main.go
@@ -0,0 +1,41 @@
+/*
+ * 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 main
+
+import (
+ "context"
+
+ "dubbo.apache.org/dubbo-go/v3"
+ _ "dubbo.apache.org/dubbo-go/v3/imports"
+ greet "github.com/apache/dubbo-go-samples/config_yaml/proto"
+ "github.com/dubbogo/gost/log/logger"
+)
+
+var svc = new(greet.GreetServiceImpl)
+
+func main() {
+ greet.SetConsumerService(svc)
+ if err := dubbo.Load(); err != nil {
+ panic(err)
+ }
+ req, err := svc.Greet(context.Background(), &greet.GreetRequest{Name: "ConfigTest"})
+ if err != nil || req.Greeting != "ConfigTest-Success" {
+ panic(err)
+ }
+ logger.Info("ConfigTest successfully")
+}
diff --git a/config_yaml/go-client/conf/dubbogo.yml b/config_yaml/go-client/conf/dubbogo.yml
new file mode 100644
index 0000000..0d34a32
--- /dev/null
+++ b/config_yaml/go-client/conf/dubbogo.yml
@@ -0,0 +1,15 @@
+# dubbo client yaml configure file
+dubbo:
+ registries:
+ demoZK:
+ protocol: zookeeper
+ timeout: 3s
+ address: 127.0.0.1:2181
+ consumer:
+ references:
+ GreetServiceImpl:
+ protocol: tri
+ interface: com.apache.dubbo.sample.Greeter
+ registry: demoZK
+ retries: 3
+ timeout: 3000
diff --git a/config_yaml/go-server/cmd/main.go b/config_yaml/go-server/cmd/main.go
new file mode 100644
index 0000000..aee6fd5
--- /dev/null
+++ b/config_yaml/go-server/cmd/main.go
@@ -0,0 +1,50 @@
+/*
+ * 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 main
+
+import (
+ "context"
+ "errors"
+ "fmt"
+
+ "dubbo.apache.org/dubbo-go/v3"
+ _ "dubbo.apache.org/dubbo-go/v3/imports"
+ greet "github.com/apache/dubbo-go-samples/config_yaml/proto"
+)
+
+type GreetTripleServer struct {
+}
+
+func (srv *GreetTripleServer) Greet(ctx context.Context, req *greet.GreetRequest) (*greet.GreetResponse, error) {
+ name := req.Name
+ if name != "ConfigTest" {
+ errInfo := fmt.Sprintf("name is not right: %s", name)
+ return nil, errors.New(errInfo)
+ }
+
+ resp := &greet.GreetResponse{Greeting: req.Name + "-Success"}
+ return resp, nil
+}
+
+func main() {
+ greet.SetProviderService(&GreetTripleServer{})
+ if err := dubbo.Load(); err != nil {
+ panic(err)
+ }
+ select {}
+}
diff --git a/config_yaml/go-server/conf/dubbogo.yml b/config_yaml/go-server/conf/dubbogo.yml
new file mode 100644
index 0000000..5eec8b7
--- /dev/null
+++ b/config_yaml/go-server/conf/dubbogo.yml
@@ -0,0 +1,15 @@
+# dubbo server yaml configure file
+dubbo:
+ registries:
+ demoZK:
+ protocol: zookeeper
+ timeout: 10s
+ address: 127.0.0.1:2181
+ protocols:
+ tripleProtocol:
+ name: tri
+ port: 20000
+ provider:
+ services:
+ GreetTripleServer:
+ interface: com.apache.dubbo.sample.Greeter
diff --git a/config_yaml/proto/greet.pb.go b/config_yaml/proto/greet.pb.go
new file mode 100644
index 0000000..ea146c7
--- /dev/null
+++ b/config_yaml/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.29.0
+// protoc v3.15.5
+// source: 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_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_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_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_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_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_greet_proto_rawDescGZIP(), []int{1}
+}
+
+func (x *GreetResponse) GetGreeting() string {
+ if x != nil {
+ return x.Greeting
+ }
+ return ""
+}
+
+var File_greet_proto protoreflect.FileDescriptor
+
+var file_greet_proto_rawDesc = []byte{
+ 0x0a, 0x0b, 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, 0x3b, 0x5a, 0x39, 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, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2f, 0x70, 0x72, 0x6f,
+ 0x74, 0x6f, 0x3b, 0x67, 0x72, 0x65, 0x65, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+}
+
+var (
+ file_greet_proto_rawDescOnce sync.Once
+ file_greet_proto_rawDescData = file_greet_proto_rawDesc
+)
+
+func file_greet_proto_rawDescGZIP() []byte {
+ file_greet_proto_rawDescOnce.Do(func() {
+ file_greet_proto_rawDescData = protoimpl.X.CompressGZIP(file_greet_proto_rawDescData)
+ })
+ return file_greet_proto_rawDescData
+}
+
+var file_greet_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
+var file_greet_proto_goTypes = []interface{}{
+ (*GreetRequest)(nil), // 0: greet.GreetRequest
+ (*GreetResponse)(nil), // 1: greet.GreetResponse
+}
+var file_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_greet_proto_init() }
+func file_greet_proto_init() {
+ if File_greet_proto != nil {
+ return
+ }
+ if !protoimpl.UnsafeEnabled {
+ file_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_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_greet_proto_rawDesc,
+ NumEnums: 0,
+ NumMessages: 2,
+ NumExtensions: 0,
+ NumServices: 1,
+ },
+ GoTypes: file_greet_proto_goTypes,
+ DependencyIndexes: file_greet_proto_depIdxs,
+ MessageInfos: file_greet_proto_msgTypes,
+ }.Build()
+ File_greet_proto = out.File
+ file_greet_proto_rawDesc = nil
+ file_greet_proto_goTypes = nil
+ file_greet_proto_depIdxs = nil
+}
diff --git a/config_yaml/proto/greet.proto b/config_yaml/proto/greet.proto
new file mode 100644
index 0000000..5320b17
--- /dev/null
+++ b/config_yaml/proto/greet.proto
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ */
+
+syntax = "proto3";
+
+package greet;
+
+option go_package = "github.com/apache/dubbo-go-samples/config_yaml/proto;greet";
+
+message GreetRequest {
+ string name = 1;
+}
+
+message GreetResponse {
+ string greeting = 1;
+}
+
+service GreetService {
+ rpc Greet(GreetRequest) returns (GreetResponse) {}
+}
\ No newline at end of file
diff --git a/config_yaml/proto/greet.triple.go b/config_yaml/proto/greet.triple.go
new file mode 100644
index 0000000..5d0c7d4
--- /dev/null
+++ b/config_yaml/proto/greet.triple.go
@@ -0,0 +1,139 @@
+/*
+ * 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-triple. DO NOT EDIT.
+//
+// Source: 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 SetConsumerService(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 SetProviderService(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/config_yaml/tests/integration/context_test.go b/integrate_test/config_yaml/tests/integration/context_test.go
new file mode 100644
index 0000000..2be7ce3
--- /dev/null
+++ b/integrate_test/config_yaml/tests/integration/context_test.go
@@ -0,0 +1,37 @@
+/*
+ * 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 integration
+
+import (
+ "context"
+ "testing"
+
+ greet "github.com/apache/dubbo-go-samples/config_yaml/proto"
+ "github.com/dubbogo/gost/log/logger"
+ "github.com/stretchr/testify/assert"
+)
+
+func TestSayHello(t *testing.T) {
+ req := &greet.GreetRequest{Name: "ConfigTest"}
+
+ reply, err := greeterProvider.Greet(context.Background(), req)
+
+ assert.Nil(t, err)
+ logger.Debug(reply)
+ assert.Equal(t, "ConfigTest-Success", reply.Greeting)
+}
diff --git a/integrate_test/config_yaml/tests/integration/main_test.go b/integrate_test/config_yaml/tests/integration/main_test.go
new file mode 100644
index 0000000..5e241e5
--- /dev/null
+++ b/integrate_test/config_yaml/tests/integration/main_test.go
@@ -0,0 +1,46 @@
+/*
+ * 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 integration
+
+import (
+ "os"
+ "testing"
+
+ "dubbo.apache.org/dubbo-go/v3/client"
+ _ "dubbo.apache.org/dubbo-go/v3/imports"
+ greet "github.com/apache/dubbo-go-samples/config_yaml/proto"
+)
+
+var greeterProvider greet.GreetService
+
+func TestMain(m *testing.M) {
+ cli, err := client.NewClient(
+ client.WithClientURL("tri://127.0.0.1:20000"),
+ )
+ if err != nil {
+ panic(err)
+ }
+
+ greeterProvider, err = greet.NewGreetService(cli)
+
+ if err != nil {
+ panic(err)
+ }
+
+ os.Exit(m.Run())
+}
diff --git a/start_integrate_test.sh b/start_integrate_test.sh
index 34bff30..1ace375 100755
--- a/start_integrate_test.sh
+++ b/start_integrate_test.sh
@@ -114,6 +114,8 @@
array+=("compatibility/registry/all/zookeeper")
array+=("compatibility/registry/all/nacos")
+# config yaml
+array+=("config_yaml")
# replace tls config
echo "The prefix of certificate path of the following files were replaced to \"$(pwd)/tls\"."
find "$(pwd)/tls" -type f -name '*.yml' -print0 | xargs -0 -n1