AlexStocks commented on code in PR #3252:
URL: https://github.com/apache/dubbo-go/pull/3252#discussion_r2990518187


##########
cluster/router/tag/router.go:
##########
@@ -102,6 +104,30 @@ func (p *PriorityRouter) Notify(invokers []base.Invoker) {
        p.Process(&config_center.ConfigChangeEvent{Key: key, Value: value, 
ConfigType: remoting.EventTypeAdd})
 }
 
+// SetStaticConfig applies a RouterConfig directly, bypassing YAML parsing.
+// This is the correct entry point for static (code-configured) rules;
+// Process is designed for dynamic config-center updates that arrive as YAML 
text.
+// Static and dynamic rules are not merged: later Process updates replace the 
current state built here.
+func (p *PriorityRouter) SetStaticConfig(cfg *global.RouterConfig) {
+       if cfg == nil || len(cfg.Tags) == 0 {

Review Comment:
   [P1] 这里缺少 `scope` 约束。tag router 的运行时查找 key 一直是“provider application + tag 
suffix”,所以只有 application-scope 规则能命中;如果用户静态注入了 `scope: service` 且带 
`tags`,这段代码仍会把规则存进去,但后续永远不会被 `Route()` 取到,表现成“配置通过但不生效”。建议和 condition router 
一样在入口处显式限制 `cfg.Scope == constant.RouterScopeApplication`,或者在 
`RouterConfig.Init()` 阶段直接拒绝 service-scope tag 规则。



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