lizining1231 commented on code in PR #3746: URL: https://github.com/apache/dubbo-go/pull/3746#discussion_r4062592432
########## tools/benchmark/client/clients/proto_fastpath_client.go: ########## @@ -0,0 +1,174 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package clients + +import ( + "bytes" + "compress/gzip" + "context" + "fmt" + "io" + "net/http" + "strings" + "sync" +) + +import ( + "google.golang.org/protobuf/proto" +) + +import ( + benchmark "dubbo.apache.org/dubbo-go/v3/tools/benchmark/proto" +) + +// ProtoFastPathClient is the prototype-shaped unary client: it talks raw +// HTTP/2 (h2c) to the Triple server and performs a unary call without going +// through duplexHTTPCall -- no io.Pipe, no per-request goroutine. It mirrors +// fastPathUnaryPing in unary_fastpath_bench_test.go, so pressure-testing it +// measures the same "fast path design" the prototype benchmark measures. +type ProtoFastPathClient struct { + httpClient *http.Client + url string + payload []byte + pool *sync.Pool +} + +// NewProtoFastPathClient builds a ProtoFastPathClient against a Triple server +// at addr. It talks plain HTTP/1.1 with no automatic gzip (DisableCompression), +// matching the wire shape of DubboGoClient (compression=none) so the A/B is +// fair; the fast-path shape itself -- no io.Pipe, no per-request goroutine, +// pooled response buffer, Content-Length -- is transport-independent. +func NewProtoFastPathClient(addr string, payload []byte) *ProtoFastPathClient { + transport := &http.Transport{DisableCompression: true} + return &ProtoFastPathClient{ + httpClient: &http.Client{Transport: transport}, + url: "http://" + addr + "/benchmark.BenchmarkService/UnaryCall", Review Comment: 谢谢评审,但是客户端用的是 h2c(明文 HTTP/2) ,见 newStreamClient :`http2.Transport{AllowHTTP: true, DialTLSContext: 纯 net.Dialer}` 。这个组合下`http://` scheme 是 让 transport 跳过 TLS 的开关 ;换成`https://` 它会去跟一个明文监听端口做 TLS 握手,直接失败。这里我就dismiss了。 -- 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]
