Copilot commented on code in PR #3357:
URL: https://github.com/apache/dubbo-go/pull/3357#discussion_r3329577875
##########
registry/servicediscovery/service_discovery_registry.go:
##########
@@ -188,6 +206,50 @@ func (s *serviceDiscoveryRegistry) UnSubscribe(url
*common.URL, listener registr
if err != nil {
return err
}
+ if id, exist := s.url.GetNonDefaultParam(constant.RegistryIdKey); exist
{
+ metadata.RemoveSubscribeURL(id, url)
+ }
+ return nil
+}
+
+func (s *serviceDiscoveryRegistry)
syncExportedMetadataAfterUnregister(removedURLs []*common.URL, keep
[]registry.ServiceInstance) error {
+ if len(removedURLs) == 0 {
+ return nil
Review Comment:
This skips metadata cleanup whenever there are no tracked `removedURLs`,
even though `Register` can already have added the provider URL to local
metadata before any service-discovery instance is created. If `UnRegister` is
called before `RegisterService` succeeds, `removedURLs` stays empty and the
exported URL/revision remain stale. The unregister path should also reconcile
the `url` passed to `UnRegister` (or otherwise handle the no-instance case)
after the unregister succeeds.
##########
metadata/metadata.go:
##########
@@ -56,3 +56,19 @@ func AddSubscribeURL(registryId string, url *common.URL) {
}
registryMetadataInfo[registryId].AddSubscribeURL(url)
}
+
+func RemoveService(registryId string, url *common.URL) {
+ metadataInfo, exist := registryMetadataInfo[registryId]
+ if !exist {
+ return
+ }
+ metadataInfo.RemoveService(url)
Review Comment:
The new top-level remove API delegates to `MetadataInfo.RemoveService`,
which deletes the `Services` entry unconditionally for the URL's match key.
Because `AddService` can store multiple exported URLs under the same service
key/protocol, removing one of them can leave other URLs in
`exportedServiceURLs` while the corresponding `ServiceInfo` has been deleted,
so subsequent metadata publication can omit a still-exported service. The
remove logic should only delete the `Services` entry when no exported URL for
that match key remains, or rebuild it from a remaining URL.
--
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]