Alanxtl commented on code in PR #3309:
URL: https://github.com/apache/dubbo-go/pull/3309#discussion_r3151804696
##########
registry/servicediscovery/service_instances_changed_listener_impl.go:
##########
@@ -183,6 +178,22 @@ func (lstn *ServiceInstancesChangedListenerImpl) OnEvent(e
observer.Event) error
return nil
}
+func toInstanceServiceURLs(instance registry.ServiceInstance, serviceInfo
*info.ServiceInfo) []*common.URL {
+ urls := instance.ToURLs(serviceInfo)
+ metadata := instance.GetMetadata()
+ if metadata == nil {
+ return urls
+ }
+ // Environment is instance-level routing metadata and is not part of
the revision hash.
+ // Prefer the fresh instance value so same-revision restarts do not
reuse stale metadata.
+ if environment := metadata[constant.EnvironmentKey]; environment != "" {
+ for _, url := range urls {
+ url.SetParam(constant.EnvironmentKey, environment)
+ }
+ }
+ return urls
+}
Review Comment:
This helper only overwrites environment when the fresh instance metadata has
a non-empty value. Since EnvironmentKey is now included in ServiceInfo params,
a same-revision restart that removes/clears environment will still build URLs
from cached metadata containing the old environment, and this branch will not
delete it. That leaves consumers routing against a stale environment. Treat
instance metadata as authoritative here: if the key is absent or empty, remove
EnvironmentKey from each synthesized 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]