xxs588 commented on code in PR #3256:
URL: https://github.com/apache/dubbo-go/pull/3256#discussion_r2946034424
##########
cluster/router/polaris/router.go:
##########
@@ -53,14 +53,39 @@ var (
func newPolarisRouter(url *common.URL) (*polarisRouter, error) {
- // get application name from url param
applicationName := url.GetParam(constant.ApplicationKey, "")
+ // then try attribute (current storage path)
if applicationName == "" {
+ if appConfRaw, ok := url.GetAttribute(constant.ApplicationKey);
ok {
+ switch appConf := appConfRaw.(type) {
+ case *global.ApplicationConfig:
+ if appConf != nil {
+ applicationName = appConf.Name
+ }
+ case global.ApplicationConfig:
+ applicationName = appConf.Name
+ }
+ }
+ }
+ // fallback to SubURL
+ if applicationName == "" && url.SubURL != nil {
applicationName = url.SubURL.GetParam(constant.ApplicationKey,
"")
if applicationName == "" {
- return nil, fmt.Errorf("polaris router must set
application name")
+ if appConfRaw, ok :=
url.SubURL.GetAttribute(constant.ApplicationKey); ok {
+ switch appConf := appConfRaw.(type) {
+ case *global.ApplicationConfig:
+ if appConf != nil {
+ applicationName = appConf.Name
+ }
+ case global.ApplicationConfig:
+ applicationName = appConf.Name
+ }
+ }
Review Comment:
感谢建议。但是之前是封装成函数的,然后之前建议修改为直接内联,避免过渡封装,所以不再抽离
--
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]