lizining1231 commented on code in PR #3706:
URL: https://github.com/apache/dubbo-go/pull/3706#discussion_r3884574592


##########
protocol/triple/client.go:
##########
@@ -181,6 +181,16 @@ func newClientManager(url *common.URL) (*clientManager, 
error) {
        }
        cliOpts = append(cliOpts, clientKeepAliveOpts...)
 
+       // The unary fast path is on by default. It only applies to the Triple
+       // (connect) protocol; the client below defaults to the gRPC wire 
format.
+       if tripleConf != nil {
+               if tripleConf.UnaryFastPath {
+                       cliOpts = append(cliOpts, tri.WithUnaryFastPath())

Review Comment:
   感谢评审,做出以下改动:
   - 测试入口改为生产链路:TripleProtocol.Refer(url) 获取真实 Invoker(URL 显式带 IDLMode=NONIDL 
确保走 NewTripleInvoker),构造真实 invocation 后经 TripleInvoker.Invoke 发起,完整经过 
parseInvocation、attachment 合并、clientManager.callUnary 的实际生产调用链;
   - 保留服务端观察点:继续通过服务端收到的 Content-Length 区分 fast path(>0)与 duplex(-1);
   - 修复测试:Refer 会启动后台 gRPC health check 流(streaming 
请求,Content-Length=-1),会覆盖服务端签名捕获,已排除 grpc.health.v1.Health/* 前缀的流后再断言
   
   mutant验证:
   protocol_grpc.go改动为
   ```go
   func (g *grpcClient) NewConn(
        ctx context.Context,
        spec Spec,
        header http.Header,
   ) StreamingClientConn {
        if deadline, ok := ctx.Deadline(); ok {
                if encodedDeadline, err := 
grpcEncodeTimeout(time.Until(deadline)); err == nil {
                        header[grpcHeaderTimeout] = []string{encodedDeadline}
                }
        }
        var call unaryClientCall
        if false && spec.StreamType == StreamTypeUnary && g.UnaryFastPath { // 
MUTANT: fast branch severed
                // Unary fast path: no io.Pipe, no per-request goroutine. 
Streaming
                // calls always keep using duplexHTTPCall.
                call = newUnaryFastPathCall(
                        ctx,
                        g.HTTPClient,
                        g.URL,
                        spec,
                        header,
                        g.BufferPool,
                )
        } else {
                call = newDuplexHTTPCall(ctx, g.HTTPClient, g.URL, spec, header)
        }
   ```
   运行
   ```bash
   GOTOOLCHAIN=go1.25.6 go test ./protocol/triple/ -run 
'TestCallUnaryFastPathWireSignature' -count=1 -v
   ```
   输出
   ```bash
   --- FAIL: TestCallUnaryFastPathWireSignature (0.01s)
       --- FAIL: TestCallUnaryFastPathWireSignature/default-on (0.01s)
           Messages: server saw Content-Length -1, want > 0 (fast path 
signature)
       --- PASS: TestCallUnaryFastPathWireSignature/explicitly-off (0.00s)
   FAIL
   ```



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