diff --git a/protocol/dubbo3/protoc-gen-dubbo3/examples/helloworld.pb.go b/protocol/dubbo3/protoc-gen-dubbo3/examples/helloworld.pb.go index ef9d6fa27a..3c695d77ee 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 b6274552f6..73156644a7 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 7d44bf7803..45de3a3ef4 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 {