Copilot commented on code in PR #3623:
URL: https://github.com/apache/dubbo-go/pull/3623#discussion_r3746588560
##########
registry/servicediscovery/service_discovery_registry.go:
##########
@@ -514,11 +514,10 @@ func (s *serviceDiscoveryRegistry) Subscribe(url
*common.URL, notify registry.No
" either specify 'provided-by' for reference or enable
metadata-report center subscription url:%s", url.String())
} else {
logger.Infof("[Registry][ServiceDiscovery] find initial mapping
applications %q for service %s", services, url.ServiceKey())
- // first notify
- err :=
mappingListener.OnEvent(registry.NewServiceMappingChangedEvent(url.ServiceKey(),
services))
- if err != nil {
- logger.Errorf("[Registry][ServiceDiscovery]
ServiceInstancesChangedListenerImpl handle error, err=%v", err)
- }
+ // Subscribe the initial applications directly. The mapping
listener tracks
+ // changes after the initial subscription; routing this event
through it
+ // makes provided-by look like an unchanged mapping and skips
SubscribeURL.
+ s.SubscribeURL(url, notify, services)
Review Comment:
After switching to direct `SubscribeURL`, the mapping listener’s baseline
(`oldServiceNames`) is no longer updated for the metadata-report mapping path
(i.e., when `provided-by` is not set and `oldServiceNames` starts empty). That
means the first later mapping update will be processed as “old is empty” and
won’t be compared against the initially subscribed application set, which can
lead to redundant re-subscribe work and stale subscriptions when mappings
change.
To preserve the previous behavior, update `mappingListener.oldServiceNames`
after the initial direct subscription so future mapping events diff against the
correct baseline.
--
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]