This is an automated email from the ASF dual-hosted git repository.
alexstocks pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo-go-samples.git
The following commit(s) were added to refs/heads/master by this push:
new e4d45eaa the example of protobuf v2 based on triple (#478)
e4d45eaa is described below
commit e4d45eaaee233d36c9cf3b20a9f7601a5ddc1ded
Author: Jingchao <[email protected]>
AuthorDate: Fri Dec 30 21:32:52 2022 +0800
the example of protobuf v2 based on triple (#478)
* feat: go to pb2 generator works
* feat: server works, move models to models pkg for avoid same generated
name
* feat: server works
* feat: go-client works
* docs: add readme for pb2
* fix: revert pb comments
* fix: importing and id upper
* style: fix with gofmt
* fix: regenerate generator.pb.go, update readme
---
go.mod | 1 +
metrics/go-server/cmd/server.go | 4 +-
registry/etcd/go-client/cmd/client.go | 4 +-
registry/etcd/go-server/cmd/server.go | 4 +-
rpc/jsonrpc/go-client/cmd/client.go | 4 +-
rpc/jsonrpc/go-server/cmd/server.go | 4 +-
rpc/triple/pb2/README.md | 62 +++
rpc/triple/pb2/README_zh.md | 67 ++++
rpc/triple/pb2/api/helloworld.pb.go | 113 ++++++
rpc/triple/pb2/api/helloworld.proto | 32 ++
rpc/triple/pb2/api/helloworld_triple.pb.go | 238 +++++++++++
rpc/triple/pb2/go-client/cmd/client.go | 108 +++++
rpc/triple/pb2/go-client/conf/dubbogo.yml | 12 +
rpc/triple/pb2/go-server/cmd/server.go | 56 +++
rpc/triple/pb2/go-server/conf/dubbogo.yml | 13 +
rpc/triple/pb2/go-server/pkg/greeter.go | 82 ++++
rpc/triple/pb2/hack/custom-boilerplate.go.txt | 0
rpc/triple/pb2/hack/gen-go-to-protobuf.sh | 27 ++
rpc/triple/pb2/models/generated.pb.go | 551 ++++++++++++++++++++++++++
rpc/triple/pb2/models/generated.proto | 22 +
rpc/triple/pb2/models/models.go | 11 +
seata-go/tcc/client/cmd/client.go | 2 +-
22 files changed, 1407 insertions(+), 10 deletions(-)
diff --git a/go.mod b/go.mod
index a6c8aef0..28cef146 100644
--- a/go.mod
+++ b/go.mod
@@ -8,6 +8,7 @@ require (
github.com/dubbogo/gost v1.13.2
github.com/dubbogo/grpc-go v1.42.10
github.com/dubbogo/triple v1.2.2-rc2
+ github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.2
github.com/opentracing/opentracing-go v1.2.0
github.com/openzipkin-contrib/zipkin-go-opentracing v0.4.5
diff --git a/metrics/go-server/cmd/server.go b/metrics/go-server/cmd/server.go
index 4f343281..2a6dd8a3 100644
--- a/metrics/go-server/cmd/server.go
+++ b/metrics/go-server/cmd/server.go
@@ -44,7 +44,9 @@ func (s *GreeterProvider) SayHello(ctx context.Context, in
*api.HelloRequest) (*
return &api.User{Name: "Hello " + in.Name, Id: "12345", Age: 21}, nil
}
-/* metrics in localhost:9090:
+/*
+ metrics in localhost:9090:
+
userCounterVec# HELP dubbo_test_counter
# TYPE dubbo_test_counter counter
dubbo_test_counter 36
diff --git a/registry/etcd/go-client/cmd/client.go
b/registry/etcd/go-client/cmd/client.go
index f7049394..da3e82dd 100644
--- a/registry/etcd/go-client/cmd/client.go
+++ b/registry/etcd/go-client/cmd/client.go
@@ -43,8 +43,8 @@ func init() {
}
// Do some checking before the system starts up:
-// 1. env config
-// `export DUBBO_GO_CONFIG_PATH= ROOT_PATH/conf/dubbogo.yml` or
`dubbogo.yaml`
+// 1. env config
+// `export DUBBO_GO_CONFIG_PATH= ROOT_PATH/conf/dubbogo.yml` or
`dubbogo.yaml`
func main() {
hessian.RegisterPOJO(&pkg.User{})
if err := config.Load(); err != nil {
diff --git a/registry/etcd/go-server/cmd/server.go
b/registry/etcd/go-server/cmd/server.go
index a2fa7da1..20c6cba3 100644
--- a/registry/etcd/go-server/cmd/server.go
+++ b/registry/etcd/go-server/cmd/server.go
@@ -43,8 +43,8 @@ var (
)
// Do some checking before the system starts up:
-// 1. env config
-// `export DUBBO_GO_CONFIG_PATH= ROOT_PATH/conf/dubbogo.yml` or
`dubbogo.yaml`
+// 1. env config
+// `export DUBBO_GO_CONFIG_PATH= ROOT_PATH/conf/dubbogo.yml` or
`dubbogo.yaml`
func main() {
hessian.RegisterPOJO(&pkg.User{})
if err := config.Load(); err != nil {
diff --git a/rpc/jsonrpc/go-client/cmd/client.go
b/rpc/jsonrpc/go-client/cmd/client.go
index 0f41861a..6fc4313c 100644
--- a/rpc/jsonrpc/go-client/cmd/client.go
+++ b/rpc/jsonrpc/go-client/cmd/client.go
@@ -52,8 +52,8 @@ func init() {
}
// Do some checking before the system starts up:
-// 1. env config
-// `export DUBBO_GO_CONFIG_PATH= ROOT_PATH/conf/dubbogo.yml` or
`dubbogo.yaml`
+// 1. env config
+// `export DUBBO_GO_CONFIG_PATH= ROOT_PATH/conf/dubbogo.yml` or
`dubbogo.yaml`
func main() {
if err := config.Load(); err != nil {
panic(err)
diff --git a/rpc/jsonrpc/go-server/cmd/server.go
b/rpc/jsonrpc/go-server/cmd/server.go
index cad1287a..ca7b87ab 100644
--- a/rpc/jsonrpc/go-server/cmd/server.go
+++ b/rpc/jsonrpc/go-server/cmd/server.go
@@ -41,8 +41,8 @@ var (
)
// Do some checking before the system starts up:
-// 1. env config
-// `export DUBBO_GO_CONFIG_PATH= ROOT_PATH/conf/dubbogo.yml` or
`dubbogo.yaml`
+// 1. env config
+// `export DUBBO_GO_CONFIG_PATH= ROOT_PATH/conf/dubbogo.yml` or
`dubbogo.yaml`
func main() {
err := config.Load()
diff --git a/rpc/triple/pb2/README.md b/rpc/triple/pb2/README.md
new file mode 100644
index 00000000..8afb8d69
--- /dev/null
+++ b/rpc/triple/pb2/README.md
@@ -0,0 +1,62 @@
+# dubbogo-grpc(pb2)
+
+This sample is a simple example of dubbo-go-grpc(pb2) with triple protocol.
+It's using `go-to-protobuf` to generate pb2 files from Go struct.
+
+
+## Contents
+
+- api: proto files for grpc and triple respectively;
+- go-server: Dubbo-go server
+- go-client: Dubbo-go client
+- models: models for Go server and client
+- hack: hack scripts for generating
+
+Please note that neither server streaming RPC nor client streaming RPC are not
supported by Triple so far.
+
+
+## Build and Run
+
+1. Install dev-tools
+
+```shell
+go install k8s.io/code-generator/cmd/go-to-protobuf@latest
+go install github.com/gogo/protobuf/protoc-gen-gogo@latest
+go install github.com/dubbogo/tools/cmd/[email protected]
+go install github.com/golang/protobuf/protoc-gen-go@latest
+```
+
+2. Generate pb files and go files
+
+```shell
+# NOTICE: make sure project in your $GOPATH/src , cause go-to-protobuf will
use $GOPATH/src as proto file path
+# using vendor as proto path
+go mod vendor
+
+# generate pb files from go struct
+bash rpc/triple/pb2/hack/gen-go-to-protobuf.sh
+
+# generate RPC go files from pb files
+protoc \
+ --proto_path=. \
+ --proto_path="$GOPATH/src" \
+ --go_out=rpc/triple/pb2/api \
+ --go-triple_out=rpc/triple/pb2/api \
+ rpc/triple/pb2/api/helloworld.proto
+
+# remove vendor
+rm -rf vendor
+```
+
+3. Run
+
+```shell
+# start a zk as a registry
+docker run --rm --name some-zookeeper -p 2181:2181 zookeeper
+
+# start server
+DUBBO_GO_CONFIG_PATH=$(pwd)/rpc/triple/pb2/go-server/conf/dubbogo.yml go run
rpc/triple/pb2/go-server/cmd/server.go
+
+# start client
+DUBBO_GO_CONFIG_PATH=$(pwd)/rpc/triple/pb2/go-client/conf/dubbogo.yml go run
rpc/triple/pb2/go-client/cmd/client.go
+```
\ No newline at end of file
diff --git a/rpc/triple/pb2/README_zh.md b/rpc/triple/pb2/README_zh.md
new file mode 100644
index 00000000..a278c5e5
--- /dev/null
+++ b/rpc/triple/pb2/README_zh.md
@@ -0,0 +1,67 @@
+# dubbogo-grpc(pb2)
+
+这个例子是 dubbo-go-grpc(pb2) 与 Triple 的一个简单例子。
+它使用 `go-to-protobuf` 从 Go 结构中生成 pb2 文件。
+
+## 内容
+
+- api: proto files for grpc and triple respectively;
+- go-server: Dubbo-go server
+- go-client: Dubbo-go client
+- models: models for Go server and client
+- hack: hack scripts for generating
+
+- api:分别用于grpc和triple的proto文件
+- go-server:dubbo-go 服务器
+- go-client:dubbo-go 的客户端
+- 模型:Go 服务器和客户端的模型
+- hack:用于生成的 hack 脚本
+
+请注意,到目前为止,Triple 还不支持服务器流式 RPC 和客户端流式 RPC。
+
+
+## 构建和运行
+
+1. 安装开发工具
+
+```shell
+go install k8s.io/code-generator/cmd/go-to-protobuf@latest
+go install github.com/gogo/protobuf/protoc-gen-gogo@latest
+go install github.com/dubbogo/tools/cmd/[email protected]
+go install github.com/golang/protobuf/protoc-gen-go@latest
+```
+
+2. 生成 pb 文件和 Go 文件
+
+```shell
+# 注意: 确保本项目在 $GOPATH/src 里面,因为 go-to-protobuf 会使用 $GOPATH/src 作为 proto 文件的路径
+# 使用 vendor 作为 proto 路径
+go mod vendor
+
+# 生成 pb 文件
+bash rpc/triple/pb2/hack/gen-go-to-protobuf.sh
+
+# 生成 RPC Go 文件 files from pb files
+protoc \
+ --proto_path=. \
+ --proto_path="$GOPATH/src" \
+ --go_out=rpc/triple/pb2/api \
+ --go-triple_out=rpc/triple/pb2/api \
+ rpc/triple/pb2/api/helloworld.proto
+
+# 清理 vendor
+rm -rf vendor
+```
+
+3. Run
+
+```shell
+# 启动 zk 作为注册中心
+docker run --rm --name some-zookeeper -p 2181:2181 zookeeper
+
+# 启动 server
+DUBBO_GO_CONFIG_PATH=$(pwd)/rpc/triple/pb2/go-server/conf/dubbogo.yml go run
rpc/triple/pb2/go-server/cmd/server.go
+
+# 启动 client
+DUBBO_GO_CONFIG_PATH=$(pwd)/rpc/triple/pb2/go-client/conf/dubbogo.yml go run
rpc/triple/pb2/go-client/cmd/client.go
+```
\ No newline at end of file
diff --git a/rpc/triple/pb2/api/helloworld.pb.go
b/rpc/triple/pb2/api/helloworld.pb.go
new file mode 100644
index 00000000..33203e49
--- /dev/null
+++ b/rpc/triple/pb2/api/helloworld.pb.go
@@ -0,0 +1,113 @@
+//
+// 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.26.0
+// protoc v3.21.12
+// source: rpc/triple/pb2/api/helloworld.proto
+
+package api
+
+import (
+ models "github.com/apache/dubbo-go-samples/rpc/triple/pb2/models"
+ protoreflect "google.golang.org/protobuf/reflect/protoreflect"
+ protoimpl "google.golang.org/protobuf/runtime/protoimpl"
+ reflect "reflect"
+)
+
+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)
+)
+
+var File_rpc_triple_pb2_api_helloworld_proto protoreflect.FileDescriptor
+
+var file_rpc_triple_pb2_api_helloworld_proto_rawDesc = []byte{
+ 0x0a, 0x23, 0x72, 0x70, 0x63, 0x2f, 0x74, 0x72, 0x69, 0x70, 0x6c, 0x65,
0x2f, 0x70, 0x62, 0x32,
+ 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f,
0x72, 0x6c, 0x64, 0x2e,
+ 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x2d, 0x6f, 0x72, 0x67, 0x2e, 0x61,
0x70, 0x61, 0x63, 0x68,
+ 0x65, 0x2e, 0x64, 0x75, 0x62, 0x62, 0x6f, 0x67, 0x6f, 0x2e, 0x73, 0x61,
0x6d, 0x70, 0x6c, 0x65,
+ 0x73, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x74, 0x72, 0x69, 0x70, 0x6c, 0x65,
0x2e, 0x70, 0x62, 0x32,
+ 0x2e, 0x61, 0x70, 0x69, 0x1a, 0x48, 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, 0x72, 0x70, 0x63,
0x2f, 0x74, 0x72, 0x69,
+ 0x70, 0x6c, 0x65, 0x2f, 0x70, 0x62, 0x32, 0x2f, 0x6d, 0x6f, 0x64, 0x65,
0x6c, 0x73, 0x2f, 0x67,
+ 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x64, 0x2e, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x32, 0xc1,
+ 0x02, 0x0a, 0x07, 0x47, 0x72, 0x65, 0x65, 0x74, 0x65, 0x72, 0x12, 0x94,
0x01, 0x0a, 0x08, 0x53,
+ 0x61, 0x79, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x12, 0x46, 0x2e, 0x67, 0x69,
0x74, 0x68, 0x75, 0x62,
+ 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x61, 0x63, 0x68, 0x65, 0x2e,
0x64, 0x75, 0x62, 0x62,
+ 0x6f, 0x5f, 0x67, 0x6f, 0x5f, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73,
0x2e, 0x72, 0x70, 0x63,
+ 0x2e, 0x74, 0x72, 0x69, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x62, 0x32, 0x2e,
0x6d, 0x6f, 0x64, 0x65,
+ 0x6c, 0x73, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x1a,
+ 0x3e, 0x2e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d,
0x2e, 0x61, 0x70, 0x61,
+ 0x63, 0x68, 0x65, 0x2e, 0x64, 0x75, 0x62, 0x62, 0x6f, 0x5f, 0x67, 0x6f,
0x5f, 0x73, 0x61, 0x6d,
+ 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x74, 0x72, 0x69,
0x70, 0x6c, 0x65, 0x2e,
+ 0x70, 0x62, 0x32, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2e, 0x55,
0x73, 0x65, 0x72, 0x22,
+ 0x00, 0x12, 0x9e, 0x01, 0x0a, 0x0e, 0x53, 0x61, 0x79, 0x48, 0x65, 0x6c,
0x6c, 0x6f, 0x53, 0x74,
+ 0x72, 0x65, 0x61, 0x6d, 0x12, 0x46, 0x2e, 0x67, 0x69, 0x74, 0x68, 0x75,
0x62, 0x2e, 0x63, 0x6f,
+ 0x6d, 0x2e, 0x61, 0x70, 0x61, 0x63, 0x68, 0x65, 0x2e, 0x64, 0x75, 0x62,
0x62, 0x6f, 0x5f, 0x67,
+ 0x6f, 0x5f, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x72, 0x70,
0x63, 0x2e, 0x74, 0x72,
+ 0x69, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x62, 0x32, 0x2e, 0x6d, 0x6f, 0x64,
0x65, 0x6c, 0x73, 0x2e,
+ 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x1a, 0x3e, 0x2e, 0x67,
+ 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70,
0x61, 0x63, 0x68, 0x65,
+ 0x2e, 0x64, 0x75, 0x62, 0x62, 0x6f, 0x5f, 0x67, 0x6f, 0x5f, 0x73, 0x61,
0x6d, 0x70, 0x6c, 0x65,
+ 0x73, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x74, 0x72, 0x69, 0x70, 0x6c, 0x65,
0x2e, 0x70, 0x62, 0x32,
+ 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2e, 0x55, 0x73, 0x65, 0x72,
0x22, 0x00, 0x28, 0x01,
+ 0x30, 0x01, 0x42, 0x08, 0x5a, 0x06, 0x2e, 0x2f, 0x3b, 0x61, 0x70, 0x69,
+}
+
+var file_rpc_triple_pb2_api_helloworld_proto_goTypes = []interface{}{
+ (*models.HelloRequest)(nil), // 0:
github.com.apache.dubbo_go_samples.rpc.triple.pb2.models.HelloRequest
+ (*models.User)(nil), // 1:
github.com.apache.dubbo_go_samples.rpc.triple.pb2.models.User
+}
+var file_rpc_triple_pb2_api_helloworld_proto_depIdxs = []int32{
+ 0, // 0:
org.apache.dubbogo.samples.rpc.triple.pb2.api.Greeter.SayHello:input_type ->
github.com.apache.dubbo_go_samples.rpc.triple.pb2.models.HelloRequest
+ 0, // 1:
org.apache.dubbogo.samples.rpc.triple.pb2.api.Greeter.SayHelloStream:input_type
-> github.com.apache.dubbo_go_samples.rpc.triple.pb2.models.HelloRequest
+ 1, // 2:
org.apache.dubbogo.samples.rpc.triple.pb2.api.Greeter.SayHello:output_type ->
github.com.apache.dubbo_go_samples.rpc.triple.pb2.models.User
+ 1, // 3:
org.apache.dubbogo.samples.rpc.triple.pb2.api.Greeter.SayHelloStream:output_type
-> github.com.apache.dubbo_go_samples.rpc.triple.pb2.models.User
+ 2, // [2:4] is the sub-list for method output_type
+ 0, // [0:2] 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_rpc_triple_pb2_api_helloworld_proto_init() }
+func file_rpc_triple_pb2_api_helloworld_proto_init() {
+ if File_rpc_triple_pb2_api_helloworld_proto != nil {
+ return
+ }
+ type x struct{}
+ out := protoimpl.TypeBuilder{
+ File: protoimpl.DescBuilder{
+ GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
+ RawDescriptor:
file_rpc_triple_pb2_api_helloworld_proto_rawDesc,
+ NumEnums: 0,
+ NumMessages: 0,
+ NumExtensions: 0,
+ NumServices: 1,
+ },
+ GoTypes:
file_rpc_triple_pb2_api_helloworld_proto_goTypes,
+ DependencyIndexes:
file_rpc_triple_pb2_api_helloworld_proto_depIdxs,
+ }.Build()
+ File_rpc_triple_pb2_api_helloworld_proto = out.File
+ file_rpc_triple_pb2_api_helloworld_proto_rawDesc = nil
+ file_rpc_triple_pb2_api_helloworld_proto_goTypes = nil
+ file_rpc_triple_pb2_api_helloworld_proto_depIdxs = nil
+}
diff --git a/rpc/triple/pb2/api/helloworld.proto
b/rpc/triple/pb2/api/helloworld.proto
new file mode 100644
index 00000000..c9f84aee
--- /dev/null
+++ b/rpc/triple/pb2/api/helloworld.proto
@@ -0,0 +1,32 @@
+/*
+ * 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 = "proto2";
+
+package org.apache.dubbogo.samples.rpc.triple.pb2.api;
+
+import
"github.com/apache/dubbo-go-samples/rpc/triple/pb2/models/generated.proto";
+
+option go_package = "./;api";
+
+// The greeting service definition.
+service Greeter {
+ // Sends a greeting
+ rpc SayHello
(github.com.apache.dubbo_go_samples.rpc.triple.pb2.models.HelloRequest) returns
(github.com.apache.dubbo_go_samples.rpc.triple.pb2.models.User) {}
+ // Sends a greeting via stream
+ rpc SayHelloStream (stream
github.com.apache.dubbo_go_samples.rpc.triple.pb2.models.HelloRequest) returns
(stream github.com.apache.dubbo_go_samples.rpc.triple.pb2.models.User) {}
+}
\ No newline at end of file
diff --git a/rpc/triple/pb2/api/helloworld_triple.pb.go
b/rpc/triple/pb2/api/helloworld_triple.pb.go
new file mode 100644
index 00000000..ff1171a5
--- /dev/null
+++ b/rpc/triple/pb2/api/helloworld_triple.pb.go
@@ -0,0 +1,238 @@
+// Code generated by protoc-gen-go-triple. DO NOT EDIT.
+// versions:
+// - protoc-gen-go-triple v1.0.8
+// - protoc v3.21.12
+// source: rpc/triple/pb2/api/helloworld.proto
+
+package api
+
+import (
+ context "context"
+ constant1 "dubbo.apache.org/dubbo-go/v3/common/constant"
+ protocol "dubbo.apache.org/dubbo-go/v3/protocol"
+ dubbo3 "dubbo.apache.org/dubbo-go/v3/protocol/dubbo3"
+ invocation "dubbo.apache.org/dubbo-go/v3/protocol/invocation"
+ fmt "fmt"
+ models "github.com/apache/dubbo-go-samples/rpc/triple/pb2/models"
+ grpc_go "github.com/dubbogo/grpc-go"
+ codes "github.com/dubbogo/grpc-go/codes"
+ metadata "github.com/dubbogo/grpc-go/metadata"
+ status "github.com/dubbogo/grpc-go/status"
+ common "github.com/dubbogo/triple/pkg/common"
+ constant "github.com/dubbogo/triple/pkg/common/constant"
+ triple "github.com/dubbogo/triple/pkg/triple"
+)
+
+// This is a compile-time assertion to ensure that this generated file
+// is compatible with the grpc package it is being compiled against.
+const _ = grpc_go.SupportPackageIsVersion7
+
+// GreeterClient is the client API for Greeter service.
+//
+// For semantics around ctx use and closing/ending streaming RPCs, please
refer to
https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
+type GreeterClient interface {
+ // Sends a greeting
+ SayHello(ctx context.Context, in *models.HelloRequest, opts
...grpc_go.CallOption) (*models.User, common.ErrorWithAttachment)
+ // Sends a greeting via stream
+ SayHelloStream(ctx context.Context, opts ...grpc_go.CallOption)
(Greeter_SayHelloStreamClient, error)
+}
+
+type greeterClient struct {
+ cc *triple.TripleConn
+}
+
+type GreeterClientImpl struct {
+ SayHello func(ctx context.Context, in *models.HelloRequest)
(*models.User, error)
+ SayHelloStream func(ctx context.Context) (Greeter_SayHelloStreamClient,
error)
+}
+
+func (c *GreeterClientImpl) GetDubboStub(cc *triple.TripleConn) GreeterClient {
+ return NewGreeterClient(cc)
+}
+
+func (c *GreeterClientImpl) XXX_InterfaceName() string {
+ return "org.apache.dubbogo.samples.rpc.triple.pb2.api.Greeter"
+}
+
+func NewGreeterClient(cc *triple.TripleConn) GreeterClient {
+ return &greeterClient{cc}
+}
+
+func (c *greeterClient) SayHello(ctx context.Context, in *models.HelloRequest,
opts ...grpc_go.CallOption) (*models.User, common.ErrorWithAttachment) {
+ out := new(models.User)
+ interfaceKey := ctx.Value(constant.InterfaceKey).(string)
+ return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/SayHello", in, out)
+}
+
+func (c *greeterClient) SayHelloStream(ctx context.Context, opts
...grpc_go.CallOption) (Greeter_SayHelloStreamClient, error) {
+ interfaceKey := ctx.Value(constant.InterfaceKey).(string)
+ stream, err := c.cc.NewStream(ctx, "/"+interfaceKey+"/SayHelloStream",
opts...)
+ if err != nil {
+ return nil, err
+ }
+ x := &greeterSayHelloStreamClient{stream}
+ return x, nil
+}
+
+type Greeter_SayHelloStreamClient interface {
+ Send(*models.HelloRequest) error
+ Recv() (*models.User, error)
+ grpc_go.ClientStream
+}
+
+type greeterSayHelloStreamClient struct {
+ grpc_go.ClientStream
+}
+
+func (x *greeterSayHelloStreamClient) Send(m *models.HelloRequest) error {
+ return x.ClientStream.SendMsg(m)
+}
+
+func (x *greeterSayHelloStreamClient) Recv() (*models.User, error) {
+ m := new(models.User)
+ if err := x.ClientStream.RecvMsg(m); err != nil {
+ return nil, err
+ }
+ return m, nil
+}
+
+// GreeterServer is the server API for Greeter service.
+// All implementations must embed UnimplementedGreeterServer
+// for forward compatibility
+type GreeterServer interface {
+ // Sends a greeting
+ SayHello(context.Context, *models.HelloRequest) (*models.User, error)
+ // Sends a greeting via stream
+ SayHelloStream(Greeter_SayHelloStreamServer) error
+ mustEmbedUnimplementedGreeterServer()
+}
+
+// UnimplementedGreeterServer must be embedded to have forward compatible
implementations.
+type UnimplementedGreeterServer struct {
+ proxyImpl protocol.Invoker
+}
+
+func (UnimplementedGreeterServer) SayHello(context.Context,
*models.HelloRequest) (*models.User, error) {
+ return nil, status.Errorf(codes.Unimplemented, "method SayHello not
implemented")
+}
+func (UnimplementedGreeterServer) SayHelloStream(Greeter_SayHelloStreamServer)
error {
+ return status.Errorf(codes.Unimplemented, "method SayHelloStream not
implemented")
+}
+func (s *UnimplementedGreeterServer) XXX_SetProxyImpl(impl protocol.Invoker) {
+ s.proxyImpl = impl
+}
+
+func (s *UnimplementedGreeterServer) XXX_GetProxyImpl() protocol.Invoker {
+ return s.proxyImpl
+}
+
+func (s *UnimplementedGreeterServer) XXX_ServiceDesc() *grpc_go.ServiceDesc {
+ return &Greeter_ServiceDesc
+}
+func (s *UnimplementedGreeterServer) XXX_InterfaceName() string {
+ return "org.apache.dubbogo.samples.rpc.triple.pb2.api.Greeter"
+}
+
+func (UnimplementedGreeterServer) mustEmbedUnimplementedGreeterServer() {}
+
+// UnsafeGreeterServer may be embedded to opt out of forward compatibility for
this service.
+// Use of this interface is not recommended, as added methods to GreeterServer
will
+// result in compilation errors.
+type UnsafeGreeterServer interface {
+ mustEmbedUnimplementedGreeterServer()
+}
+
+func RegisterGreeterServer(s grpc_go.ServiceRegistrar, srv GreeterServer) {
+ s.RegisterService(&Greeter_ServiceDesc, srv)
+}
+
+func _Greeter_SayHello_Handler(srv interface{}, ctx context.Context, dec
func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor)
(interface{}, error) {
+ in := new(models.HelloRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ base := srv.(dubbo3.Dubbo3GrpcService)
+ args := []interface{}{}
+ args = append(args, in)
+ md, _ := metadata.FromIncomingContext(ctx)
+ invAttachment := make(map[string]interface{}, len(md))
+ for k, v := range md {
+ invAttachment[k] = v
+ }
+ invo := invocation.NewRPCInvocation("SayHello", args, invAttachment)
+ if interceptor == nil {
+ result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
+ return result, result.Error()
+ }
+ info := &grpc_go.UnaryServerInfo{
+ Server: srv,
+ FullMethod: ctx.Value("XXX_TRIPLE_GO_INTERFACE_NAME").(string),
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{},
error) {
+ result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
+ return result, result.Error()
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+func _Greeter_SayHelloStream_Handler(srv interface{}, stream
grpc_go.ServerStream) error {
+ _, ok := srv.(dubbo3.Dubbo3GrpcService)
+ ctx := stream.Context()
+ md, _ := metadata.FromIncomingContext(ctx)
+ invAttachment := make(map[string]interface{}, len(md))
+ for k, v := range md {
+ invAttachment[k] = v
+ }
+ stream.(grpc_go.CtxSetterStream).SetContext(context.WithValue(ctx,
constant1.AttachmentKey, invAttachment))
+ invo := invocation.NewRPCInvocation("SayHelloStream", nil, nil)
+ if !ok {
+ fmt.Println(invo)
+ return nil
+ }
+ return
srv.(GreeterServer).SayHelloStream(&greeterSayHelloStreamServer{stream})
+}
+
+type Greeter_SayHelloStreamServer interface {
+ Send(*models.User) error
+ Recv() (*models.HelloRequest, error)
+ grpc_go.ServerStream
+}
+
+type greeterSayHelloStreamServer struct {
+ grpc_go.ServerStream
+}
+
+func (x *greeterSayHelloStreamServer) Send(m *models.User) error {
+ return x.ServerStream.SendMsg(m)
+}
+
+func (x *greeterSayHelloStreamServer) Recv() (*models.HelloRequest, error) {
+ m := new(models.HelloRequest)
+ if err := x.ServerStream.RecvMsg(m); err != nil {
+ return nil, err
+ }
+ return m, nil
+}
+
+// Greeter_ServiceDesc is the grpc_go.ServiceDesc for Greeter service.
+// It's only intended for direct use with grpc_go.RegisterService,
+// and not to be introspected or modified (even as a copy)
+var Greeter_ServiceDesc = grpc_go.ServiceDesc{
+ ServiceName: "org.apache.dubbogo.samples.rpc.triple.pb2.api.Greeter",
+ HandlerType: (*GreeterServer)(nil),
+ Methods: []grpc_go.MethodDesc{
+ {
+ MethodName: "SayHello",
+ Handler: _Greeter_SayHello_Handler,
+ },
+ },
+ Streams: []grpc_go.StreamDesc{
+ {
+ StreamName: "SayHelloStream",
+ Handler: _Greeter_SayHelloStream_Handler,
+ ServerStreams: true,
+ ClientStreams: true,
+ },
+ },
+ Metadata: "rpc/triple/pb2/api/helloworld.proto",
+}
diff --git a/rpc/triple/pb2/go-client/cmd/client.go
b/rpc/triple/pb2/go-client/cmd/client.go
new file mode 100644
index 00000000..0b260621
--- /dev/null
+++ b/rpc/triple/pb2/go-client/cmd/client.go
@@ -0,0 +1,108 @@
+/*
+ * 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"
+)
+
+import (
+ "dubbo.apache.org/dubbo-go/v3/config"
+ _ "dubbo.apache.org/dubbo-go/v3/imports"
+
+ "github.com/dubbogo/gost/log/logger"
+ tripleConstant "github.com/dubbogo/triple/pkg/common/constant"
+)
+
+import (
+ "github.com/apache/dubbo-go-samples/rpc/triple/pb2/api"
+ "github.com/apache/dubbo-go-samples/rpc/triple/pb2/models"
+)
+
+var greeterProvider = new(api.GreeterClientImpl)
+
+func init() {
+ config.SetConsumerService(greeterProvider)
+}
+
+// export
DUBBO_GO_CONFIG_PATH=$PATH_TO_SAMPLES/rpc/triple/pb2/go-client/conf/dubbogo.yml
+func main() {
+ if err := config.Load(); err != nil {
+ panic(err)
+ }
+
+ stream()
+ unary()
+}
+
+func stream() {
+ logger.Infof(">>>>> Dubbo-go client is about to call to SayHelloStream")
+
+ ctx := context.Background()
+ ctx = context.WithValue(ctx, tripleConstant.TripleCtxKey("tri-req-id"),
"triple-request-id-demo")
+
+ req := models.HelloRequest{
+ Name: "laurence",
+ }
+
+ r, err := greeterProvider.SayHelloStream(ctx)
+ if err != nil {
+ panic(err)
+ }
+
+ for i := 0; i < 2; i++ {
+ if err := r.Send(&req); err != nil {
+ logger.Errorf("Send SayHelloStream num %d request error
= %v\n", i+1, err)
+ return
+ }
+ }
+
+ rspUser := &models.User{}
+ if err := r.RecvMsg(rspUser); err != nil {
+ logger.Errorf("Receive 1 SayHelloStream response user error =
%v\n", err)
+ return
+ }
+ logger.Infof("Receive 1 user = %+v\n", rspUser)
+ if err := r.Send(&req); err != nil {
+ logger.Errorf("Send SayHelloStream num %d request error =
%v\n", 3, err)
+ return
+ }
+ rspUser2 := &models.User{}
+ if err := r.RecvMsg(rspUser2); err != nil {
+ logger.Errorf("Receive 2 SayHelloStream response user error =
%v\n", err)
+ return
+ }
+ logger.Infof("Receive 2 user = %+v\n", rspUser2)
+}
+
+func unary() {
+ logger.Infof(">>>>> Dubbo-go client is about to call to SayHello")
+
+ ctx := context.Background()
+ ctx = context.WithValue(ctx,
tripleConstant.TripleCtxKey(tripleConstant.TripleRequestID),
"triple-request-id-demo")
+
+ req := models.HelloRequest{
+ Name: "laurence",
+ }
+ user, err := greeterProvider.SayHello(ctx, &req)
+ if err != nil {
+ panic(err)
+ }
+
+ logger.Infof("Receive user = %+v\n", user)
+}
diff --git a/rpc/triple/pb2/go-client/conf/dubbogo.yml
b/rpc/triple/pb2/go-client/conf/dubbogo.yml
new file mode 100644
index 00000000..cbb3e538
--- /dev/null
+++ b/rpc/triple/pb2/go-client/conf/dubbogo.yml
@@ -0,0 +1,12 @@
+dubbo:
+ registries:
+ zk:
+ address: zookeeper://127.0.0.1:2181
+ consumer:
+ references:
+ GreeterClientImpl:
+ protocol: tri
+ metrics:
+ enable: false
+ path: /custom-metrics-path
+ port: 9092
diff --git a/rpc/triple/pb2/go-server/cmd/server.go
b/rpc/triple/pb2/go-server/cmd/server.go
new file mode 100644
index 00000000..14857066
--- /dev/null
+++ b/rpc/triple/pb2/go-server/cmd/server.go
@@ -0,0 +1,56 @@
+package main
+
+import (
+ "fmt"
+ "os"
+ "os/signal"
+ "syscall"
+ "time"
+)
+
+import (
+ "dubbo.apache.org/dubbo-go/v3/config"
+ _ "dubbo.apache.org/dubbo-go/v3/imports"
+
+ "github.com/dubbogo/gost/log/logger"
+
+ "github.com/apache/dubbo-go-samples/rpc/triple/pb2/go-server/pkg"
+ _ "github.com/dubbogo/triple/pkg/triple"
+)
+
+var (
+ survivalTimeout = int(3 * time.Second)
+)
+
+// export
DUBBO_GO_CONFIG_PATH=$PATH_TO_SAMPLES/rpc/triple/pb2/go-server/conf/dubbogo.yml
+func main() {
+ config.SetProviderService(&pkg.GreeterProvider{})
+ if err := config.Load(); err != nil {
+ panic(err)
+ }
+ initSignal()
+}
+
+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, syscall.SIGINT)
+ for {
+ sig := <-signals
+ logger.Infof("get signal %s", sig.String())
+ switch sig {
+ case syscall.SIGHUP:
+ // reload()
+ default:
+ time.Sleep(time.Second * 5)
+ 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
+ }
+ }
+}
diff --git a/rpc/triple/pb2/go-server/conf/dubbogo.yml
b/rpc/triple/pb2/go-server/conf/dubbogo.yml
new file mode 100644
index 00000000..fd6cc762
--- /dev/null
+++ b/rpc/triple/pb2/go-server/conf/dubbogo.yml
@@ -0,0 +1,13 @@
+dubbo:
+ registries:
+ zk:
+ address: zookeeper://127.0.0.1:2181
+ protocols:
+ triple:
+ name: tri
+ port: 20000
+ provider:
+ services:
+ GreeterProvider:
+ # interface read from pb file
+ interface: ""
\ No newline at end of file
diff --git a/rpc/triple/pb2/go-server/pkg/greeter.go
b/rpc/triple/pb2/go-server/pkg/greeter.go
new file mode 100644
index 00000000..7350ee4a
--- /dev/null
+++ b/rpc/triple/pb2/go-server/pkg/greeter.go
@@ -0,0 +1,82 @@
+/*
+ * 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 pkg
+
+import (
+ "context"
+ "fmt"
+)
+
+import (
+ "github.com/dubbogo/gost/log/logger"
+
+ tripleConstant "github.com/dubbogo/triple/pkg/common/constant"
+)
+
+import (
+ "github.com/apache/dubbo-go-samples/rpc/triple/pb2/api"
+ "github.com/apache/dubbo-go-samples/rpc/triple/pb2/models"
+)
+
+type GreeterProvider struct {
+ api.UnimplementedGreeterServer
+}
+
+func (s *GreeterProvider) SayHelloStream(svr api.Greeter_SayHelloStreamServer)
error {
+ c, err := svr.Recv()
+ if err != nil {
+ return err
+ }
+ logger.Infof("Dubbo-go3 GreeterProvider recv 1 user, name = %s\n",
c.Name)
+ c2, err := svr.Recv()
+ if err != nil {
+ return err
+ }
+ logger.Infof("Dubbo-go3 GreeterProvider recv 2 user, name = %s\n",
c2.Name)
+
+ err = svr.Send(&models.User{
+ Name: "hello " + c.Name,
+ Age: 18,
+ ID: "123456789",
+ })
+ if err != nil {
+ return err
+ }
+ c3, err := svr.Recv()
+ if err != nil {
+ return err
+ }
+ logger.Infof("Dubbo-go3 GreeterProvider recv 3 user, name = %s\n",
c3.Name)
+
+ err = svr.Send(&models.User{
+ Name: "hello " + c2.Name,
+ Age: 19,
+ ID: "123456789",
+ })
+ if err != nil {
+ return err
+ }
+ return nil
+}
+
+func (s *GreeterProvider) SayHello(ctx context.Context, in
*models.HelloRequest) (*models.User, error) {
+ logger.Infof("Dubbo3 GreeterProvider get user name = %s\n" + in.Name)
+ fmt.Println("get triple header tri-req-id = ",
ctx.Value(tripleConstant.TripleCtxKey(tripleConstant.TripleRequestID)))
+ fmt.Println("get triple header tri-service-version = ",
ctx.Value(tripleConstant.TripleCtxKey(tripleConstant.TripleServiceVersion)))
+ return &models.User{Name: "Hello " + in.Name, ID: "12345", Age: 21}, nil
+}
diff --git a/rpc/triple/pb2/hack/custom-boilerplate.go.txt
b/rpc/triple/pb2/hack/custom-boilerplate.go.txt
new file mode 100644
index 00000000..e69de29b
diff --git a/rpc/triple/pb2/hack/gen-go-to-protobuf.sh
b/rpc/triple/pb2/hack/gen-go-to-protobuf.sh
new file mode 100644
index 00000000..30d40e58
--- /dev/null
+++ b/rpc/triple/pb2/hack/gen-go-to-protobuf.sh
@@ -0,0 +1,27 @@
+#!/bin/bash
+# This script using protoc to generate go code from proto files.
+# it support k8s.io
+
+CURRENT_DIR=$(cd "$(dirname "$0")"; pwd)
+
+# --apimachinery-packages string
+# comma-separated list of directories to get apimachinery input types from
which are needed by any API.
+# Directories prefixed with '-' are not generated, directories prefixed with
'+' only create types with explicit IDL instructions.
+# (default
"+k8s.io/apimachinery/pkg/util/intstr,+k8s.io/apimachinery/pkg/api/resource,+k8s.io/apimachinery/pkg/runtime/schema,+k8s.io/apimachinery/pkg/runtime,k8s.io/apimachinery/pkg/apis/meta/v1,k8s.io/apimachinery/pkg/apis/meta/v1beta1,k8s.io/apimachinery/pkg/apis/testapigroup/v1")
+APIMACHINERY_PKGS=(
+)
+# temporal not supported now, because pb3 not supported now
+# go.temporal.io/api/workflow/v1
+
+# add your go models package here
+goModels=(
+ github.com/apache/dubbo-go-samples/rpc/triple/pb2/models
+)
+
+packages=$(IFS=, ; echo "${goModels[*]}")
+
+go-to-protobuf \
+ --go-header-file="$CURRENT_DIR/../hack/custom-boilerplate.go.txt" \
+ --packages="$packages" \
+ --apimachinery-packages=$(IFS=, ; echo "${APIMACHINERY_PKGS[*]}") \
+ --proto-import=./vendor
diff --git a/rpc/triple/pb2/models/generated.pb.go
b/rpc/triple/pb2/models/generated.pb.go
new file mode 100644
index 00000000..0e05a6da
--- /dev/null
+++ b/rpc/triple/pb2/models/generated.pb.go
@@ -0,0 +1,551 @@
+// Code generated by protoc-gen-gogo. DO NOT EDIT.
+// source:
github.com/apache/dubbo-go-samples/rpc/triple/pb2/models/generated.proto
+
+package models
+
+import (
+ fmt "fmt"
+
+ io "io"
+ math "math"
+ math_bits "math/bits"
+ reflect "reflect"
+ strings "strings"
+
+ proto "github.com/gogo/protobuf/proto"
+)
+
+// Reference imports to suppress errors if they are not otherwise used.
+var _ = proto.Marshal
+var _ = fmt.Errorf
+var _ = math.Inf
+
+// This is a compile-time assertion to ensure that this generated file
+// is compatible with the proto package it is being compiled against.
+// A compilation error at this line likely means your copy of the
+// proto package needs to be updated.
+const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
+
+func (m *HelloRequest) Reset() { *m = HelloRequest{} }
+func (*HelloRequest) ProtoMessage() {}
+func (*HelloRequest) Descriptor() ([]byte, []int) {
+ return fileDescriptor_13c2da724194d7d4, []int{0}
+}
+func (m *HelloRequest) XXX_Unmarshal(b []byte) error {
+ return m.Unmarshal(b)
+}
+func (m *HelloRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte,
error) {
+ b = b[:cap(b)]
+ n, err := m.MarshalToSizedBuffer(b)
+ if err != nil {
+ return nil, err
+ }
+ return b[:n], nil
+}
+func (m *HelloRequest) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_HelloRequest.Merge(m, src)
+}
+func (m *HelloRequest) XXX_Size() int {
+ return m.Size()
+}
+func (m *HelloRequest) XXX_DiscardUnknown() {
+ xxx_messageInfo_HelloRequest.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_HelloRequest proto.InternalMessageInfo
+
+func (m *User) Reset() { *m = User{} }
+func (*User) ProtoMessage() {}
+func (*User) Descriptor() ([]byte, []int) {
+ return fileDescriptor_13c2da724194d7d4, []int{1}
+}
+func (m *User) XXX_Unmarshal(b []byte) error {
+ return m.Unmarshal(b)
+}
+func (m *User) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ b = b[:cap(b)]
+ n, err := m.MarshalToSizedBuffer(b)
+ if err != nil {
+ return nil, err
+ }
+ return b[:n], nil
+}
+func (m *User) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_User.Merge(m, src)
+}
+func (m *User) XXX_Size() int {
+ return m.Size()
+}
+func (m *User) XXX_DiscardUnknown() {
+ xxx_messageInfo_User.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_User proto.InternalMessageInfo
+
+func init() {
+ proto.RegisterType((*HelloRequest)(nil),
"github.com.apache.dubbo_go_samples.rpc.triple.pb2.models.HelloRequest")
+ proto.RegisterType((*User)(nil),
"github.com.apache.dubbo_go_samples.rpc.triple.pb2.models.User")
+}
+
+func init() {
+
proto.RegisterFile("github.com/apache/dubbo-go-samples/rpc/triple/pb2/models/generated.proto",
fileDescriptor_13c2da724194d7d4)
+}
+
+var fileDescriptor_13c2da724194d7d4 = []byte{
+ // 289 bytes of a gzipped FileDescriptorProto
+ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0xd0,
0xb1, 0x4e, 0xeb, 0x30,
+ 0x14, 0x06, 0xe0, 0x38, 0xcd, 0x1d, 0xae, 0xe9, 0x94, 0xa9, 0xaa, 0x84,
0x1b, 0x75, 0xea, 0x12,
+ 0x1b, 0x75, 0xea, 0x4a, 0xc4, 0x50, 0x16, 0x86, 0x48, 0x2c, 0x0c, 0x54,
0x76, 0x72, 0x70, 0x23,
+ 0x25, 0xb5, 0x71, 0x92, 0x9d, 0x47, 0xe0, 0xb1, 0x32, 0x76, 0xec, 0x54,
0x11, 0xf3, 0x22, 0x08,
+ 0x27, 0x02, 0x16, 0x16, 0x36, 0xff, 0xf6, 0xaf, 0xcf, 0x47, 0x07, 0x6f,
0x65, 0xd1, 0xec, 0x5b,
+ 0x41, 0x33, 0x55, 0x31, 0xae, 0x79, 0xb6, 0x07, 0x96, 0xb7, 0x42, 0xa8,
0x58, 0xaa, 0xb8, 0xe6,
+ 0x95, 0x2e, 0xa1, 0x66, 0x46, 0x67, 0xac, 0x31, 0x85, 0x2e, 0x81, 0x69,
0xb1, 0x66, 0x95, 0xca,
+ 0xa1, 0xac, 0x99, 0x84, 0x03, 0x18, 0xde, 0x40, 0x4e, 0xb5, 0x51, 0x8d,
0x0a, 0x37, 0xdf, 0x12,
+ 0x1d, 0x24, 0xea, 0xa4, 0x9d, 0x54, 0xbb, 0x51, 0xa2, 0x46, 0x67, 0x74,
0x90, 0xa8, 0x16, 0x6b,
+ 0x3a, 0x48, 0xf3, 0xf8, 0xc7, 0x0c, 0x52, 0x49, 0xc5, 0x1c, 0x28, 0xda,
0x27, 0x97, 0x5c, 0x70,
+ 0xa7, 0xe1, 0xa3, 0xe5, 0x15, 0x9e, 0x6e, 0xa1, 0x2c, 0x55, 0x0a, 0xcf,
0x2d, 0xd4, 0x4d, 0x18,
+ 0xe1, 0xe0, 0xc0, 0x2b, 0x98, 0xa1, 0x08, 0xad, 0xfe, 0x27, 0xd3, 0xee,
0xbc, 0xf0, 0xec, 0x79,
+ 0x11, 0xdc, 0xf1, 0x0a, 0x52, 0xf7, 0xb2, 0xcc, 0x70, 0x70, 0x5f, 0x83,
0x09, 0xe7, 0xd8, 0x2f,
+ 0xf2, 0xb1, 0x87, 0xc7, 0x9e, 0x7f, 0x7b, 0x93, 0xfa, 0x45, 0xfe, 0xa5,
0xf8, 0xbf, 0x29, 0xe1,
+ 0x25, 0x9e, 0x70, 0x09, 0xb3, 0x49, 0x84, 0x56, 0xff, 0x92, 0x8b, 0xb1,
0x30, 0xb9, 0x96, 0x90,
+ 0x7e, 0xde, 0x27, 0x8f, 0x5d, 0x4f, 0xbc, 0x63, 0x4f, 0xbc, 0x53, 0x4f,
0xbc, 0x17, 0x4b, 0x50,
+ 0x67, 0x09, 0x3a, 0x5a, 0x82, 0x4e, 0x96, 0xa0, 0x37, 0x4b, 0xd0, 0xeb,
0x3b, 0xf1, 0x1e, 0x36,
+ 0x7f, 0xdd, 0xf7, 0x47, 0x00, 0x00, 0x00, 0xff, 0xff, 0x4e, 0xdb, 0x96,
0xb5, 0xaa, 0x01, 0x00,
+ 0x00,
+}
+
+func (m *HelloRequest) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalToSizedBuffer(dAtA[:size])
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *HelloRequest) MarshalTo(dAtA []byte) (int, error) {
+ size := m.Size()
+ return m.MarshalToSizedBuffer(dAtA[:size])
+}
+
+func (m *HelloRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
+ i := len(dAtA)
+ _ = i
+ var l int
+ _ = l
+ i -= len(m.Name)
+ copy(dAtA[i:], m.Name)
+ i = encodeVarintGenerated(dAtA, i, uint64(len(m.Name)))
+ i--
+ dAtA[i] = 0xa
+ return len(dAtA) - i, nil
+}
+
+func (m *User) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalToSizedBuffer(dAtA[:size])
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *User) MarshalTo(dAtA []byte) (int, error) {
+ size := m.Size()
+ return m.MarshalToSizedBuffer(dAtA[:size])
+}
+
+func (m *User) MarshalToSizedBuffer(dAtA []byte) (int, error) {
+ i := len(dAtA)
+ _ = i
+ var l int
+ _ = l
+ i = encodeVarintGenerated(dAtA, i, uint64(m.Age))
+ i--
+ dAtA[i] = 0x18
+ i -= len(m.Name)
+ copy(dAtA[i:], m.Name)
+ i = encodeVarintGenerated(dAtA, i, uint64(len(m.Name)))
+ i--
+ dAtA[i] = 0x12
+ i -= len(m.ID)
+ copy(dAtA[i:], m.ID)
+ i = encodeVarintGenerated(dAtA, i, uint64(len(m.ID)))
+ i--
+ dAtA[i] = 0xa
+ return len(dAtA) - i, nil
+}
+
+func encodeVarintGenerated(dAtA []byte, offset int, v uint64) int {
+ offset -= sovGenerated(v)
+ base := offset
+ for v >= 1<<7 {
+ dAtA[offset] = uint8(v&0x7f | 0x80)
+ v >>= 7
+ offset++
+ }
+ dAtA[offset] = uint8(v)
+ return base
+}
+func (m *HelloRequest) Size() (n int) {
+ if m == nil {
+ return 0
+ }
+ var l int
+ _ = l
+ l = len(m.Name)
+ n += 1 + l + sovGenerated(uint64(l))
+ return n
+}
+
+func (m *User) Size() (n int) {
+ if m == nil {
+ return 0
+ }
+ var l int
+ _ = l
+ l = len(m.ID)
+ n += 1 + l + sovGenerated(uint64(l))
+ l = len(m.Name)
+ n += 1 + l + sovGenerated(uint64(l))
+ n += 1 + sovGenerated(uint64(m.Age))
+ return n
+}
+
+func sovGenerated(x uint64) (n int) {
+ return (math_bits.Len64(x|1) + 6) / 7
+}
+func sozGenerated(x uint64) (n int) {
+ return sovGenerated(uint64((x << 1) ^ uint64((int64(x) >> 63))))
+}
+func (this *HelloRequest) String() string {
+ if this == nil {
+ return "nil"
+ }
+ s := strings.Join([]string{`&HelloRequest{`,
+ `Name:` + fmt.Sprintf("%v", this.Name) + `,`,
+ `}`,
+ }, "")
+ return s
+}
+func (this *User) String() string {
+ if this == nil {
+ return "nil"
+ }
+ s := strings.Join([]string{`&User{`,
+ `ID:` + fmt.Sprintf("%v", this.ID) + `,`,
+ `Name:` + fmt.Sprintf("%v", this.Name) + `,`,
+ `Age:` + fmt.Sprintf("%v", this.Age) + `,`,
+ `}`,
+ }, "")
+ return s
+}
+func valueToStringGenerated(v interface{}) string {
+ rv := reflect.ValueOf(v)
+ if rv.IsNil() {
+ return "nil"
+ }
+ pv := reflect.Indirect(rv).Interface()
+ return fmt.Sprintf("*%v", pv)
+}
+func (m *HelloRequest) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowGenerated
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= uint64(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: HelloRequest: wiretype end
group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: HelloRequest: illegal tag %d
(wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d
for field Name", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowGenerated
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= uint64(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthGenerated
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex < 0 {
+ return ErrInvalidLengthGenerated
+ }
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Name = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipGenerated(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if (skippy < 0) || (iNdEx+skippy) < 0 {
+ return ErrInvalidLengthGenerated
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *User) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowGenerated
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= uint64(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: User: wiretype end group for
non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: User: illegal tag %d (wire
type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d
for field ID", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowGenerated
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= uint64(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthGenerated
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex < 0 {
+ return ErrInvalidLengthGenerated
+ }
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.ID = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d
for field Name", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowGenerated
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= uint64(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthGenerated
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex < 0 {
+ return ErrInvalidLengthGenerated
+ }
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Name = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ case 3:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d
for field Age", wireType)
+ }
+ m.Age = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowGenerated
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.Age |= int32(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ default:
+ iNdEx = preIndex
+ skippy, err := skipGenerated(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if (skippy < 0) || (iNdEx+skippy) < 0 {
+ return ErrInvalidLengthGenerated
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func skipGenerated(dAtA []byte) (n int, err error) {
+ l := len(dAtA)
+ iNdEx := 0
+ depth := 0
+ for iNdEx < l {
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return 0, ErrIntOverflowGenerated
+ }
+ if iNdEx >= l {
+ return 0, io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ wireType := int(wire & 0x7)
+ switch wireType {
+ case 0:
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return 0, ErrIntOverflowGenerated
+ }
+ if iNdEx >= l {
+ return 0, io.ErrUnexpectedEOF
+ }
+ iNdEx++
+ if dAtA[iNdEx-1] < 0x80 {
+ break
+ }
+ }
+ case 1:
+ iNdEx += 8
+ case 2:
+ var length int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return 0, ErrIntOverflowGenerated
+ }
+ if iNdEx >= l {
+ return 0, io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ length |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if length < 0 {
+ return 0, ErrInvalidLengthGenerated
+ }
+ iNdEx += length
+ case 3:
+ depth++
+ case 4:
+ if depth == 0 {
+ return 0, ErrUnexpectedEndOfGroupGenerated
+ }
+ depth--
+ case 5:
+ iNdEx += 4
+ default:
+ return 0, fmt.Errorf("proto: illegal wireType %d",
wireType)
+ }
+ if iNdEx < 0 {
+ return 0, ErrInvalidLengthGenerated
+ }
+ if depth == 0 {
+ return iNdEx, nil
+ }
+ }
+ return 0, io.ErrUnexpectedEOF
+}
+
+var (
+ ErrInvalidLengthGenerated = fmt.Errorf("proto: negative length
found during unmarshaling")
+ ErrIntOverflowGenerated = fmt.Errorf("proto: integer overflow")
+ ErrUnexpectedEndOfGroupGenerated = fmt.Errorf("proto: unexpected end of
group")
+)
diff --git a/rpc/triple/pb2/models/generated.proto
b/rpc/triple/pb2/models/generated.proto
new file mode 100644
index 00000000..e07dfdbb
--- /dev/null
+++ b/rpc/triple/pb2/models/generated.proto
@@ -0,0 +1,22 @@
+
+// This file was autogenerated by go-to-protobuf. Do not edit it manually!
+
+syntax = "proto2";
+
+package github.com.apache.dubbo_go_samples.rpc.triple.pb2.models;
+
+// Package-wide variables from generator "generated".
+option go_package = "github.com/apache/dubbo-go-samples/rpc/triple/pb2/models";
+
+message HelloRequest {
+ optional string name = 1;
+}
+
+message User {
+ optional string id = 1;
+
+ optional string name = 2;
+
+ optional int32 age = 3;
+}
+
diff --git a/rpc/triple/pb2/models/models.go b/rpc/triple/pb2/models/models.go
new file mode 100644
index 00000000..54802f79
--- /dev/null
+++ b/rpc/triple/pb2/models/models.go
@@ -0,0 +1,11 @@
+package models
+
+type User struct {
+ ID string `protobuf:"bytes,1,opt,name=id" json:"id,omitempty"`
+ Name string `protobuf:"bytes,2,opt,name=name" json:"name,omitempty"`
+ Age int32 `protobuf:"varint,3,opt,name=age" json:"age,omitempty"`
+}
+
+type HelloRequest struct {
+ Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
+}
diff --git a/seata-go/tcc/client/cmd/client.go
b/seata-go/tcc/client/cmd/client.go
index 3876a30e..2553ac9f 100644
--- a/seata-go/tcc/client/cmd/client.go
+++ b/seata-go/tcc/client/cmd/client.go
@@ -36,7 +36,7 @@ import (
)
// need to setup environment variable "DUBBO_GO_CONFIG_PATH" to
"seata-go/tcc/client/conf/dubbogo.yml"
-//and run "seata-go/tcc/server/cmd/server.go" before run
+// and run "seata-go/tcc/server/cmd/server.go" before run
func main() {
integration.UseDubbo()
config.SetConsumerService(service.UserProviderInstance)