Merge pull request #725 from Yan0613/main
[feat]: add new sample multirpc
diff --git a/README.md b/README.md
index 70af2ea..d5360f0 100644
--- a/README.md
+++ b/README.md
@@ -21,6 +21,7 @@
* logger: dubbogo logging
* mesh: give an proxy service mesh example which shows how to deploy the dubbo-go services with envoy on kubernetes platform
* metrics: show how to collect dubbogo prometheus metrics
+* multirpc: show how to use three protocols(triple, dubbo, jsonrpc) in one server and invoke them on the client-side
* otel/trace: show how to use opentelemetry as dubbogo tracing tool
* proxyless: give an proxyless service mesh example which shows how to deploy the dubbo-go services on kubernetes platform
* registry: show how to use etcd/nacos/polaris/zookeeper as dubbogo registry
diff --git a/helloworld/README.md b/helloworld/README.md
index 6f87752..b9adb4c 100644
--- a/helloworld/README.md
+++ b/helloworld/README.md
@@ -1,4 +1,4 @@
-# Helloworld for dubbo-go
+# MultiRpc for dubbo-go
This example demonstrates the basic usage of dubbo-go as an RPC framework. Check [Quick Start][] on our official website for detailed explanation.
diff --git a/integrate_test/multirpc/tests/integration/main_test.go b/integrate_test/multirpc/tests/integration/main_test.go
new file mode 100644
index 0000000..391e0c3
--- /dev/null
+++ b/integrate_test/multirpc/tests/integration/main_test.go
@@ -0,0 +1,81 @@
+/*
+ * 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 (
+ "dubbo.apache.org/dubbo-go/v3/common/constant"
+ "os"
+ "testing"
+
+ "dubbo.apache.org/dubbo-go/v3/client"
+ greet "github.com/apache/dubbo-go-samples/multirpc/proto"
+
+ _ "dubbo.apache.org/dubbo-go/v3/imports"
+)
+
+var greeterProvider greet.GreetService
+var connDubbo *client.Connection
+var connJsonRpc *client.Connection
+
+func TestMain(m *testing.M) {
+ //Triple
+ cliTriple, err := client.NewClient(
+ client.WithClientURL("tri://127.0.0.1:20000"),
+ )
+ if err != nil {
+ panic(err)
+ }
+
+ greeterProvider, err = greet.NewGreetService(cliTriple)
+
+ if err != nil {
+ panic(err)
+ }
+
+ //Dubbo
+ cliDubbo, err := client.NewClient(
+ client.WithClientURL("dubbo://127.0.0.1:20001"),
+ client.WithClientProtocolDubbo(),
+ client.WithClientSerialization(constant.Hessian2Serialization),
+ )
+ if err != nil {
+ panic(err)
+ }
+
+ connDubbo, err = cliDubbo.Dial("GreetProvider")
+ if err != nil {
+ panic(err)
+ }
+
+ //JsonRpc
+ cliJsonRpc, err := client.NewClient(
+ client.WithClientURL("jsonrpc://127.0.0.1:20002"),
+ client.WithClientProtocolJsonRPC(),
+ client.WithClientSerialization(constant.JSONSerialization),
+ )
+ if err != nil {
+ panic(err)
+ }
+
+ connJsonRpc, err = cliJsonRpc.Dial("GreetProvider")
+
+ if err != nil {
+ panic(err)
+ }
+ os.Exit(m.Run())
+}
diff --git a/integrate_test/multirpc/tests/integration/multirpc_test.go b/integrate_test/multirpc/tests/integration/multirpc_test.go
new file mode 100644
index 0000000..e51802d
--- /dev/null
+++ b/integrate_test/multirpc/tests/integration/multirpc_test.go
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package integration
+
+import (
+ "context"
+ "github.com/dubbogo/gost/log/logger"
+ "testing"
+
+ greet "github.com/apache/dubbo-go-samples/multirpc/proto"
+ "github.com/stretchr/testify/assert"
+)
+
+func TestSayHello(t *testing.T) {
+ //Triple
+ req := &greet.GreetRequest{Name: "hello world"}
+
+ ctx := context.Background()
+
+ reply, err := greeterProvider.Greet(ctx, req)
+
+ assert.Nil(t, err)
+ assert.Equal(t, "hello world", reply.Greeting)
+ logger.Infof("GreetProvider.Greet reply: %s", reply.Greeting)
+
+ //Dubbo
+ var respDubbo string
+ if err = connDubbo.CallUnary(context.Background(), []interface{}{"hello", "new", "dubbo"}, &respDubbo, "SayHello"); err != nil {
+ logger.Errorf("GreetProvider.Greet err: %s", err)
+ return
+ }
+ assert.Nil(t, err)
+ assert.Equal(t, "hellonewdubbo", respDubbo)
+
+ //JsonRpc
+ var respJsonRpc string
+ if err = connJsonRpc.CallUnary(context.Background(), []interface{}{"hello", "new", "jsonrpc"}, &respJsonRpc, "SayHello"); err != nil {
+ logger.Errorf("GreetProvider.Greet err: %s", err)
+ return
+ }
+ assert.Nil(t, err)
+ assert.Equal(t, "hellonewjsonrpc", respJsonRpc)
+}
diff --git a/multirpc/README.md b/multirpc/README.md
new file mode 100644
index 0000000..9e21598
--- /dev/null
+++ b/multirpc/README.md
@@ -0,0 +1,78 @@
+# Helloworld for dubbo-go
+
+This example demonstrates the basic usage of dubbo-go as an RPC framework. Check [Quick Start][] on our official website for detailed explanation.
+
+## Contents
+
+- server/main.go - is the main definition of the service, handler and rpc server
+- client/main.go - is the rpc client
+- proto - contains the protobuf definition of the API
+
+## How to run
+
+[//]: # (### Prerequisites)
+
+[//]: # ()
+[//]: # (1. Install `protoc [version3][]`)
+
+[//]: # ()
+[//]: # ( Please refer to [Protocol Buffer Compiler Installation][].)
+
+[//]: # ()
+[//]: # (2. Install `protoc-gen-go` and `protoc-gen-triple` )
+
+[//]: # ()
+[//]: # ( ```shell)
+
+[//]: # ( # install the version of your choice of protoc-gen-go. here use the latest version as example)
+
+[//]: # ( go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.31)
+
+[//]: # ( )
+[//]: # ( # install the latest version of protoc-gen-triple)
+
+[//]: # ( git clone https://github.com/apache/dubbo-go.git && cd ./dubbo-go)
+
+[//]: # ( git checkout feature-triple)
+
+[//]: # ( go mod tidy)
+
+[//]: # ( cd ./protocol/triple/triple-tool/protoc-gen-triple)
+
+[//]: # ( go install .)
+
+[//]: # ( ```)
+
+[//]: # ()
+[//]: # (### Generate stub code)
+
+[//]: # ()
+[//]: # (```shell)
+
+[//]: # (# generate related stub code with protoc-gen-go and protoc-gen-triple)
+
+[//]: # (protoc --go_out=. --go_opt=paths=source_relative --triple_out=. --triple_opt=paths=source_relative ./greet.proto)
+
+[//]: # (```)
+
+### Run server
+```shell
+go run ./server/main.go
+```
+
+test server work as expected:
+```shell
+curl \
+ --header "Content-Type: application/json" \
+ --data '{"name": "Dubbo"}' \
+ http://localhost:20000/greet.GreetService/Greet
+```
+
+### Run client
+```shell
+go run ./client/main.go
+```
+
+[Quick Start]: https://dubbo-next.staged.apache.org/zh-cn/overview/mannual/golang-sdk/quickstart/
+[version3]: https://protobuf.dev/programming-guides/proto3/
+[Protocol Buffer Compiler Installation]: https://dubbo-next.staged.apache.org/zh-cn/overview/reference/protoc-installation/
\ No newline at end of file
diff --git a/multirpc/go-client/cmd/main.go b/multirpc/go-client/cmd/main.go
new file mode 100644
index 0000000..b74a973
--- /dev/null
+++ b/multirpc/go-client/cmd/main.go
@@ -0,0 +1,97 @@
+/*
+ * 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/client"
+ "dubbo.apache.org/dubbo-go/v3/common/constant"
+ _ "dubbo.apache.org/dubbo-go/v3/imports"
+ "dubbo.apache.org/dubbo-go/v3/registry"
+ greet "github.com/apache/dubbo-go-samples/multirpc/proto"
+ "github.com/dubbogo/gost/log/logger"
+)
+
+func main() {
+ ins, err := dubbo.NewInstance(
+ dubbo.WithName("dubbo_multirpc_client"),
+ dubbo.WithRegistry(
+ registry.WithZookeeper(),
+ registry.WithAddress("127.0.0.1:2181"),
+ ),
+ )
+ if err != nil {
+ panic(err)
+ }
+
+ //Triple
+ cli, err := ins.NewClient(
+ client.WithClientProtocolTriple())
+ if err != nil {
+ panic(err)
+ }
+ svc, err := greet.NewGreetService(cli)
+ if err != nil {
+ panic(err)
+ }
+
+ respTriple, err := svc.Greet(context.Background(), &greet.GreetRequest{Name: "hello world"})
+ if err != nil {
+ logger.Error(err)
+ }
+ logger.Infof("Greet triple response: %s", respTriple.Greeting)
+
+ //Duboo
+ cliDubbo, err := ins.NewClient(
+ client.WithClientProtocolDubbo(),
+ client.WithClientSerialization(constant.Hessian2Serialization),
+ )
+ if err != nil {
+ panic(err)
+ }
+
+ connDubbo, err := cliDubbo.Dial("GreetProvider")
+ if err != nil {
+ panic(err)
+ }
+ var respDubbo string
+ if err = connDubbo.CallUnary(context.Background(), []interface{}{"hello", "new", "dubbo"}, &respDubbo, "SayHello"); err != nil {
+ logger.Errorf("GreetProvider.Greet err: %s", err)
+ return
+ }
+ logger.Infof("Get dubbo Response: %s", respDubbo)
+
+ //JsonRpc
+ cliJsonRpc, err := ins.NewClient(
+ client.WithClientProtocolJsonRPC(),
+ client.WithClientSerialization(constant.JSONSerialization),
+ )
+ if err != nil {
+ panic(err)
+ }
+ connJsonRpc, err := cliJsonRpc.Dial("GreetProvider")
+ if err != nil {
+ panic(err)
+ }
+ var respJsonRpc string
+ if err := connJsonRpc.CallUnary(context.Background(), []interface{}{"hello", "new", "jsonrpc"}, &respJsonRpc, "SayHello"); err != nil {
+ logger.Errorf("GreetProvider.Greet err: %s", err)
+ return
+ }
+ logger.Infof("Get jsonrpc Response: %s", respJsonRpc)
+}
diff --git a/multirpc/go-server/cmd/main.go b/multirpc/go-server/cmd/main.go
new file mode 100644
index 0000000..44dda5d
--- /dev/null
+++ b/multirpc/go-server/cmd/main.go
@@ -0,0 +1,100 @@
+/*
+ * 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"
+ "dubbo.apache.org/dubbo-go/v3/protocol"
+ "dubbo.apache.org/dubbo-go/v3/registry"
+ "dubbo.apache.org/dubbo-go/v3/server"
+ greet "github.com/apache/dubbo-go-samples/multirpc/proto"
+ "github.com/dubbogo/gost/log/logger"
+)
+
+type GreetMultiRPCServer struct {
+}
+
+func (srv *GreetMultiRPCServer) Greet(ctx context.Context, req *greet.GreetRequest) (*greet.GreetResponse, error) {
+ resp := &greet.GreetResponse{Greeting: req.Name}
+ return resp, nil
+}
+
+type GreetProvider struct {
+}
+
+func (*GreetProvider) SayHello(req string, req1 string, req2 string) (string, error) {
+ return req + req1 + req2, nil
+}
+
+func main() {
+ ins, err := dubbo.NewInstance(
+ dubbo.WithName("dubbo_multirpc_server"),
+ dubbo.WithRegistry(
+ registry.WithZookeeper(),
+ registry.WithAddress("127.0.0.1:2181"),
+ ),
+ dubbo.WithProtocol(
+ protocol.WithTriple(),
+ protocol.WithPort(20000)),
+ dubbo.WithProtocol(
+ protocol.WithDubbo(),
+ protocol.WithPort(20001)),
+ dubbo.WithProtocol(
+ protocol.WithJSONRPC(),
+ protocol.WithPort(20002)),
+ )
+ if err != nil {
+ panic(err)
+ }
+ //Triple
+ srvTriple, err := ins.NewServer()
+ if err != nil {
+ panic(err)
+ }
+ if err = greet.RegisterGreetServiceHandler(srvTriple, &GreetMultiRPCServer{}); err != nil {
+ panic(err)
+ }
+ if err = srvTriple.Serve(); err != nil {
+ logger.Error(err)
+ }
+
+ //Dubbo
+ srvDubbo, err := ins.NewServer()
+ if err != nil {
+ panic(err)
+ }
+ if err = srvDubbo.Register(&GreetProvider{}, nil, server.WithInterface("GreetProvider")); err != nil {
+ panic(err)
+ }
+ if err = srvDubbo.Serve(); err != nil {
+ logger.Error(err)
+ }
+
+ //JsonRpc
+ srvJsonRpc, err := ins.NewServer()
+ if err != nil {
+ panic(err)
+ }
+ if err = srvJsonRpc.Register(&GreetProvider{}, nil, server.WithInterface("GreetProvider")); err != nil {
+ panic(err)
+ }
+ if err := srvJsonRpc.Serve(); err != nil {
+ logger.Error(err)
+ }
+}
diff --git a/multirpc/proto/greet.pb.go b/multirpc/proto/greet.pb.go
new file mode 100644
index 0000000..ea146c7
--- /dev/null
+++ b/multirpc/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/multirpc/proto/greet.proto b/multirpc/proto/greet.proto
new file mode 100644
index 0000000..d2c1e1b
--- /dev/null
+++ b/multirpc/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/multirpc/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/multirpc/proto/greet.triple.go b/multirpc/proto/greet.triple.go
new file mode 100644
index 0000000..5d0c7d4
--- /dev/null
+++ b/multirpc/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/start_integrate_test.sh b/start_integrate_test.sh
index e4aea94..5c77200 100755
--- a/start_integrate_test.sh
+++ b/start_integrate_test.sh
@@ -61,6 +61,9 @@
#timeout
array+=("timeout")
+#multirpc
+array+=("multirpc")
+
#healthcheck
array+=("healthcheck")