lizining1231 commented on PR #3706:
URL: https://github.com/apache/dubbo-go/pull/3706#issuecomment-5503446123

   > `UnaryFastPath` 是普通 `bool`,未赋值时默认就是 `false`:
   > 
   > 如果我传入其他配置 但是不传入UnaryFastPath
   > 
   > ```go
   > cfg := &global.TripleConfig{
   >     KeepAliveInterval: "10s",
   > }
   > // cfg.UnaryFastPath == false 如果不显式指定会被默认赋值为false
   > ```
   > 
   > 会导致 默认值是true 但是如果显式指定了其他的配置而不指定UnaryFastPath会变成false
   
   感谢 review!的确,`UnaryFastPath` 之前是普通 `bool`,零值 `false`。任何不经过 
`DefaultTripleConfig()` 构造的 `TripleConfig`(比如手动 
`&TripleConfig{KeepAliveInterval: "10s"}`),该字段都会退化为 `false`,导致默认开启的快路径被意外关闭。
   
   已修复,具体改动如下:
   
   代码改动:
   
   `UnaryFastPath bool` → `UnaryFastPath *bool`,语义为:
   
   | 取值 | 含义 | 行为 |
   | --- | --- | --- |
   | `nil` | 未显式设置 | 走默认(开启) |
   | `true` | 显式开启 | 开启 |
   | `false` | 显式关闭 | 关闭(回滚) |
   
   - `DefaultTripleConfig()` 填 `&true`,保证默认开启
   - `Clone()` 对 `*bool` 做深拷贝,对齐 `global` 包既有风格
   - 消费点(`protocol/triple/client.go`)改为 `UnaryFastPath == nil || 
*UnaryFastPath` 判断
   - yaml/json 缺省时字段为 `nil`,与旧配置兼容;仅显式赋值处需要适配
   
   测试改动:
   
   在 `TestCallUnaryFastPathWireSignature`中补充用例:
   
   - `default-on`:`tripleConf == nil` → 快路径开启
   - `explicitly-on`:`UnaryFastPath: true` → 快路径开启
   - `explicitly-off`:`UnaryFastPath: false` → 回退 duplex
   - `unset-keeps-default`:`&TripleConfig{KeepAliveInterval: "10s"}`不设开关→ 
快路径仍保持开启


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