Copilot commented on code in PR #3372:
URL: https://github.com/apache/dubbo-go/pull/3372#discussion_r3367022697


##########
registry/protocol/protocol.go:
##########
@@ -129,6 +128,109 @@ func (proto *registryProtocol) 
initConfigurationListeners(url *common.URL) {
        proto.providerConfigurationListener = 
newProviderConfigurationListener(proto.overrideListeners, url)
 }
 
+// ensureShutdownAttributes resolves shutdown config by priority:
+// url attribute, fallbackURL attribute, then global default.
+// It writes the resolved config to url and, when missing, fallbackURL.
+func ensureShutdownAttributes(url *common.URL, fallbackURL *common.URL) 
*global.ShutdownConfig {
+       if shutdownConfig, ok := shutdownFromAttribute(url); ok {
+               url.SetAttribute(constant.ShutdownConfigPrefix, shutdownConfig)
+               ensureFallbackShutdownAttribute(fallbackURL, shutdownConfig)
+               return shutdownConfig
+       }
+       if shutdownConfig, ok := shutdownFromAttribute(fallbackURL); ok {
+               url.SetAttribute(constant.ShutdownConfigPrefix, shutdownConfig)
+               return shutdownConfig
+       }
+
+       shutdownConfig := global.DefaultShutdownConfig()
+       url.SetAttribute(constant.ShutdownConfigPrefix, shutdownConfig)
+       ensureFallbackShutdownAttribute(fallbackURL, shutdownConfig)
+       return shutdownConfig
+}
+
+func ensureFallbackShutdownAttribute(url *common.URL, shutdownConfig 
*global.ShutdownConfig) {
+       if url == nil {
+               return
+       }
+       if _, ok := url.GetAttribute(constant.ShutdownConfigPrefix); !ok {
+               url.SetAttribute(constant.ShutdownConfigPrefix, shutdownConfig)
+       }
+}
+
+func shutdownFromAttribute(url *common.URL) (*global.ShutdownConfig, bool) {
+       if url == nil {
+               return nil, false
+       }
+
+       shutdownRaw, ok := url.GetAttribute(constant.ShutdownConfigPrefix)
+       if !ok {
+               return nil, false
+       }
+       shutdownConfig, ok := shutdownRaw.(*global.ShutdownConfig)
+       return shutdownConfig, ok && shutdownConfig != nil
+}
+
+func ensureApplicationAttribute(url *common.URL, fallbackURL *common.URL) 
*global.ApplicationConfig {
+       if application, ok := applicationFromAttribute(url); ok {
+               url.SetAttribute(constant.ApplicationKey, application)
+               return application
+       }

Review Comment:
   The application-resolution helpers 
(ensureApplicationAttribute/applicationFromAttribute/applicationFromParam) 
added here are essentially duplicated in registry/directory/directory.go with 
slightly different signatures. This duplication increases the risk of the two 
call sites drifting (e.g., future changes to accepted attribute types or 
precedence rules), which would make behavior inconsistent between 
provider/export and consumer/directory paths. Consider extracting this logic 
into a shared helper (e.g., a small internal package under registry/ or 
common/) that both packages can call, to keep the resolution rules centralized.



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