AlexStocks commented on code in PR #3252:
URL: https://github.com/apache/dubbo-go/pull/3252#discussion_r2990635812
##########
cluster/router/chain/chain.go:
##########
@@ -110,6 +111,83 @@ func (c *RouterChain) copyRouters()
[]router.PriorityRouter {
return ret
}
+// getApplicationName gets the application name from URL with fallback to
SubURL
+func getApplicationName(url *common.URL) string {
+ appName := url.GetParam(constant.ApplicationKey, "")
+ if appName == "" && url.SubURL != nil {
+ appName = url.SubURL.GetParam(constant.ApplicationKey, "")
+ }
+ return appName
+}
+
+// isRouterMatch checks if router configuration matches the current
service/application
+func isRouterMatch(routerCfg *global.RouterConfig, url *common.URL, appName
string) bool {
+ switch routerCfg.Scope {
+ case constant.RouterScopeService:
+ if url.SubURL != nil {
+ return routerCfg.Key == url.SubURL.ServiceKey()
+ }
+ return routerCfg.Key == url.ServiceKey()
+ case constant.RouterScopeApplication:
Review Comment:
[P1] 这里按 consumer URL 的 application 过滤 application-scope 规则,但 tag router
运行时取 key 的地方是 `invokers[0].GetURL().GetParam(application)`,也就是 provider
application。两边语义不一致:规则能在初始化时注入进去,真正路由时却会用另一套 key 去查,application-scope 的静态 tag
规则只有在 consumer/provider application 恰好同名时才会生效。建议把 application-scope 静态规则的匹配和存储
key 统一到同一侧,否则这个特性本身就是不稳定的。
--
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]