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/07/23 09:12:58 UTC

[GitHub] [dubbo-go] LaurenceLiZhixin commented on a change in pull request #1339: Use class name as the default reference name

LaurenceLiZhixin commented on a change in pull request #1339:
URL: https://github.com/apache/dubbo-go/pull/1339#discussion_r675418196



##########
File path: config/service.go
##########
@@ -17,37 +17,43 @@
 
 package config
 
+import (
+	"reflect"
+)
+
 import (
 	"dubbo.apache.org/dubbo-go/v3/common"
 )
 
 var (
-	conServices = map[string]common.RPCService{} // service name -> service
-	proServices = map[string]common.RPCService{} // service name -> service
+	conServices = map[string]interface{}{} // service name -> service
+	proServices = map[string]interface{}{} // service name -> service
 )
 
 // SetConsumerService is called by init() of implement of RPCService
-func SetConsumerService(service common.RPCService) {
-	conServices[service.Reference()] = service
+func SetConsumerService(service interface{}) {
+	ref := reflect.TypeOf(service).Elem().Name()
+	conServices[ref] = service
 }
 
 // SetProviderService is called by init() of implement of RPCService
-func SetProviderService(service common.RPCService) {
-	proServices[service.Reference()] = service
+func SetProviderService(service interface{}) {
+	ref := reflect.TypeOf(service).Elem().Name()

Review comment:
       这里有点小问题。
   需要考虑是指针还是结构,还需要考虑包名的问题。如果用户在package pkg 下面定义了一个User结构,传入的是指针,这个ref将为“*pkg.User”,而用户希望用“User”作为key,这里可以做一下调整。




-- 
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