AlexStocks commented on PR #3252:
URL: https://github.com/apache/dubbo-go/pull/3252#issuecomment-4106487511

   ## Review 反馈 - 已改进问题分析
   
   ### 1. ✅ API 语义统一问题(已解决)
   
   **原问题(Alanxtl & AlexStocks):** setRouters、WithClientRouter、SetClientRouters 
三个函数语义混乱,部分是 append,部分是覆盖。
   
   **改进情况:**
   - `setRouters()` (line 530): 已改为 replace 语义,注释明确标注为内部函数
   - `WithClientRouter()` (line 863): 保持 append 语义,注释明确标注为用户侧 API
   - `SetClientRouters()` (line 997): replace 语义,注释明确标注为内部函数,不建议用户使用
   
   **评价:** ✅ 已解决。注释清晰,语义明确,用户侧只暴露 append 语义的 WithClientRouter。
   
   ---
   
   ### 2. ✅ 深拷贝问题(已解决)
   
   **原问题(Alanxtl & AlexStocks):** injectRouterConfig 直接传递指针,可能导致配置被外部修改。
   
   **改进情况:**
   ```go
   // cluster/router/chain/chain.go:177-186
   func (c *RouterChain) injectRouterConfig(routerCfg *global.RouterConfig) {
       routerCfgCopy := routerCfg.Clone()  // 第一次克隆
       
       for _, r := range c.routers {
           if setter, ok := r.(router.StaticConfigSetter); ok {
               setter.SetStaticConfig(routerCfgCopy.Clone())  // 每个 router 再次克隆
           }
       }
   }
   ```
   
   **评价:** ✅ 已解决。实现了双重克隆保护,确保配置隔离。


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