You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2021/11/21 09:52:59 UTC

[GitHub] [dubbo-go] LaurenceLiZhixin commented on pull request #1603: Ftr/triple reflect support

LaurenceLiZhixin commented on pull request #1603:
URL: https://github.com/apache/dubbo-go/pull/1603#issuecomment-974785819


   目前 Dubbo-go service 需要用户在配置中填写 InterfacenName,但由于 pb 文件的接口名规范是从pb文件内读取的,也就是proto 文件中的 package 字段,例如:
   ```proto
   
   syntax = "proto3";
   
   option go_package = "github.com/dubbogo/grpc-go/reflection/triple_reflection_v1alpha";
   
   package triple.reflection.v1alpha;
   
   service UserProvider {
   }
   ```
   在这种规范下,UserProvider 的接口全名为 triple.reflection.v1alpha.UserProvider,框架需要遵循 pb 文件的接口名,才能保证跨语言互通,与 grpc 互通。
   Triple 之前的实现,为了兼容用户interfaceName 编写习惯,忽略了pb 中的接口名,强制使用用户在配置中定义的interfaceName 作为接口名。但在 pb 反射支持之后,这将带来问题,因为pb 文件中的接口名是静态的,用户配置中的接口名是动态的。
   
   经过考虑,我选择了这种方式来解决冲突:如果用户在配置中定义interfaceName,将优先使用该字段。如果未定义,会从pb 文件中读取package name。用户未定义接口名的情况,只能出现在 triple 协议 pb 序列化的情况下。这种设计与之前完全兼容。
   
   从pb文件中读取package name的接口会在 _triple.pb.go 文件中定义
   protoc-gen-go-triple@v1.0.5 之后支持,与旧版本兼容:
   ```go
   func (s *UnimplementedGreeterServer) XXX_InterfaceName() string {
   	return "org.apache.dubbogo.samples.api.Greeter"
   }
   ```
   @AlexStocks 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org