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/01/19 15:03:00 UTC

[GitHub] [dubbo-go] cityiron commented on a change in pull request #948: Fix: make metadata report work without serviceDiscovery

cityiron commented on a change in pull request #948:
URL: https://github.com/apache/dubbo-go/pull/948#discussion_r560242458



##########
File path: metadata/service/remote/service.go
##########
@@ -116,22 +116,41 @@ func (mts *MetadataService) UnsubscribeURL(url *common.URL) error {
 func (mts *MetadataService) PublishServiceDefinition(url *common.URL) error {
 	interfaceName := url.GetParam(constant.INTERFACE_KEY, "")
 	isGeneric := url.GetParamBool(constant.GENERIC_KEY, false)
-	if len(interfaceName) > 0 && !isGeneric {
-		sv := common.ServiceMap.GetServiceByServiceKey(url.Protocol, url.ServiceKey())
-		sd := definition.BuildServiceDefinition(*sv, url)
+	if common.RoleType(common.PROVIDER).Role() == url.GetParam(constant.SIDE_KEY, "") {
+		if len(interfaceName) > 0 && !isGeneric {
+			sv := common.ServiceMap.GetServiceByServiceKey(url.Protocol, url.ServiceKey())
+			sd := definition.BuildServiceDefinition(*sv, url)
+			id := &identifier.MetadataIdentifier{
+				BaseMetadataIdentifier: identifier.BaseMetadataIdentifier{
+					ServiceInterface: interfaceName,
+					Version:          url.GetParam(constant.VERSION_KEY, ""),
+					Group:            url.GetParam(constant.GROUP_KEY, constant.DUBBO),
+					Side:             url.GetParam(constant.SIDE_KEY, "provider"),
+				},
+			}
+			mts.delegateReport.StoreProviderMetadata(id, sd)
+			return nil
+		}
+		logger.Errorf("publishProvider interfaceName is empty . providerUrl:%v ", url)
+	} else {
+		params := make(map[string]string, len(url.GetParams()))
+		url.RangeParams(func(key, value string) bool {
+			params[key] = value
+			return true
+		})
 		id := &identifier.MetadataIdentifier{
 			BaseMetadataIdentifier: identifier.BaseMetadataIdentifier{
 				ServiceInterface: interfaceName,
 				Version:          url.GetParam(constant.VERSION_KEY, ""),
 				// Group:            url.GetParam(constant.GROUP_KEY, constant.SERVICE_DISCOVERY_DEFAULT_GROUP),
 				Group: url.GetParam(constant.GROUP_KEY, constant.DUBBO),
-				Side:  url.GetParam(constant.SIDE_KEY, "provider"),
+				Side:  url.GetParam(constant.SIDE_KEY, "consumer"),

Review comment:
       SIDE_KEY  consumer and provider shoud refer from constant




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

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