Alanxtl commented on code in PR #3369:
URL: https://github.com/apache/dubbo-go/pull/3369#discussion_r3368873638


##########
metadata/report_instance.go:
##########
@@ -41,6 +42,12 @@ var (
        instances = make(map[string]report.MetadataReport)
 )
 
+// ClearMetadataReportInstances resets the package-level instances map.
+// Intended for test isolation only; do not call in production code.
+func ClearMetadataReportInstances() {
+       instances = make(map[string]report.MetadataReport)
+}

Review Comment:
   这个函数移到test里面就行了吧



##########
metadata/mapping/metadata/service_name_mapping.go:
##########
@@ -96,11 +97,23 @@ func (d *ServiceNameMapping) Get(url *common.URL, listener 
mapping.MappingListen
        return metadataReport.GetServiceAppMapping(serviceInterface, 
DefaultGroup, listener)
 }
 
+// Remove removes the service-to-app mapping for the given URL from all
+// registered metadata reports. Unlike Map (which stops on the first failure),
+// Remove is best-effort: it attempts every report and returns all errors
+// joined together so the caller can see the full failure picture. The
+// intent is to avoid leaving stale entries in any registry due to a transient
+// error in one of the others.
 func (d *ServiceNameMapping) Remove(url *common.URL) error {
        serviceInterface := url.GetParam(constant.InterfaceKey, "")
-       metadataReport := metadata.GetMetadataReport()
-       if metadataReport == nil {
+       metadataReports := metadata.GetMetadataReports()
+       if len(metadataReports) == 0 {

Review Comment:
   ```suggestion
        metadataReports := metadata.GetMetadataReports()
        if metadataReport == nil || len(metadataReports) == 0 {
   ```
   nil不需要处理了吗



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to