You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by al...@apache.org on 2021/06/07 02:41:10 UTC

[dubbo-go] branch 3.0 updated: Feat: add grpc provider reference in codes generated by protoc-gen-dubbo3 (#1240)

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

alexstocks pushed a commit to branch 3.0
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git


The following commit(s) were added to refs/heads/3.0 by this push:
     new 3e881f6  Feat: add grpc provider reference in codes generated by protoc-gen-dubbo3 (#1240)
3e881f6 is described below

commit 3e881f6d05fbdd35727a5a620fb78014b1d2a263
Author: Laurence <45...@users.noreply.github.com>
AuthorDate: Mon Jun 7 10:41:02 2021 +0800

    Feat: add grpc provider reference in codes generated by protoc-gen-dubbo3 (#1240)
    
    * fix: change 3.0 triple provider reference
    
    * fix: change 3.0 triple provider reference
    
    * Fix: add liscence
---
 protocol/dubbo3/protoc-gen-dubbo3/examples/helloworld.pb.go | 4 ++++
 protocol/dubbo3/protoc-gen-dubbo3/plugin/dubbo3/dubbo3.go   | 6 ++++++
 protocol/grpc/protoc-gen-dubbo/plugin/dubbo/dubbo.go        | 6 ++++++
 3 files changed, 16 insertions(+)

diff --git a/protocol/dubbo3/protoc-gen-dubbo3/examples/helloworld.pb.go b/protocol/dubbo3/protoc-gen-dubbo3/examples/helloworld.pb.go
index ef9d6fa..3c695d7 100644
--- a/protocol/dubbo3/protoc-gen-dubbo3/examples/helloworld.pb.go
+++ b/protocol/dubbo3/protoc-gen-dubbo3/examples/helloworld.pb.go
@@ -279,6 +279,10 @@ func (s *GreeterProviderBase) GetProxyImpl() protocol.Invoker {
 	return s.proxyImpl
 }
 
+func (c *GreeterProviderBase) Reference() string {
+	return "greeterImpl"
+}
+
 func _DUBBO_Greeter_SayHello_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
 	in := new(HelloRequest)
 	if err := dec(in); err != nil {
diff --git a/protocol/dubbo3/protoc-gen-dubbo3/plugin/dubbo3/dubbo3.go b/protocol/dubbo3/protoc-gen-dubbo3/plugin/dubbo3/dubbo3.go
index b627455..7315664 100644
--- a/protocol/dubbo3/protoc-gen-dubbo3/plugin/dubbo3/dubbo3.go
+++ b/protocol/dubbo3/protoc-gen-dubbo3/plugin/dubbo3/dubbo3.go
@@ -240,6 +240,12 @@ func (g *dubboGrpc) generateService(file *generator.FileDescriptor, service *pb.
 	g.P("}")
 	g.P()
 
+	// return reference
+	g.P("func (c *", serverType, ") ", " Reference() string ", "{")
+	g.P(`return "`, unexport(servName), `Impl"`)
+	g.P("}")
+	g.P()
+
 	// add handler
 	var handlerNames []string
 	for _, method := range service.Method {
diff --git a/protocol/grpc/protoc-gen-dubbo/plugin/dubbo/dubbo.go b/protocol/grpc/protoc-gen-dubbo/plugin/dubbo/dubbo.go
index 7d44bf7..45de3a3 100644
--- a/protocol/grpc/protoc-gen-dubbo/plugin/dubbo/dubbo.go
+++ b/protocol/grpc/protoc-gen-dubbo/plugin/dubbo/dubbo.go
@@ -188,6 +188,12 @@ func (g *dubboGrpc) generateService(file *generator.FileDescriptor, service *pb.
 	g.P("}")
 	g.P()
 
+	// return reference
+	g.P("func (c *", serverType, ") ", " Reference() string ", "{")
+	g.P(`return "`, unexport(servName), `Impl"`)
+	g.P("}")
+	g.P()
+
 	// add handler
 	var handlerNames []string
 	for _, method := range service.Method {