baerwang commented on issue #2031:
URL: https://github.com/apache/dubbo-go/issues/2031#issuecomment-1296885998

   ```go
   func MergeURL(serviceURL *URL, referenceURL *URL) *URL {
        // After Clone, it is a new URL that there is no thread safe issue.
        mergedURL := serviceURL.Clone()
        // iterator the referenceURL if serviceURL not have the key ,merge in
        // referenceURL usually will not changed. so change RangeParams to 
GetParams to avoid the string value copy.// Group get group
        for key, value := range referenceURL.GetParams() {
                if _, ok := mergedURL.GetNonDefaultParam(key); !ok {
                        if len(value) > 0 {
                                mergedURL.params[key] = value
                        }
                }
        }
   
        // loadBalance,cluster,retries strategy config
        methodConfigMergeFcn := mergeNormalParam(mergedURL.params, 
referenceURL, []string{constant.LoadbalanceKey, constant.ClusterKey, 
constant.RetriesKey, constant.TimeoutKey})
   
        // remote timestamp
        if v, ok := serviceURL.GetNonDefaultParam(constant.TimestampKey); !ok {
                mergedURL.params[constant.RemoteTimestampKey] = []string{v}
                mergedURL.params[constant.TimestampKey] = 
[]string{referenceURL.GetParam(constant.TimestampKey, "")}
        }
   
        // finally execute methodConfigMergeFcn
        for _, method := range referenceURL.Methods {
                for _, fcn := range methodConfigMergeFcn {
                        fcn("methods." + method)
                }
        }
        // In this way, we will raise some performance.
        return mergedURL
   }
   ```


-- 
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: notifications-unsubscr...@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@dubbo.apache.org
For additional commands, e-mail: notifications-h...@dubbo.apache.org

Reply via email to