zbchi commented on code in PR #3281:
URL: https://github.com/apache/dubbo-go/pull/3281#discussion_r3006113492


##########
protocol/triple/dual_transport.go:
##########
@@ -0,0 +1,350 @@
+/*
+ * 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 triple
+
+import (
+       "context"
+       "crypto/tls"
+       "errors"
+       "io"
+       "net/http"
+       "net/url"
+       "sync"
+       "time"
+)
+
+import (
+       "github.com/dubbogo/gost/log/logger"
+
+       "github.com/quic-go/quic-go"
+       "github.com/quic-go/quic-go/http3"
+
+       "golang.org/x/net/http2"
+)
+
+import (
+       tri "dubbo.apache.org/dubbo-go/v3/protocol/triple/triple_protocol"
+)
+
+type originMode int
+
+const (
+       // originUnknown means the origin has not advertised HTTP/3 yet.
+       originUnknown originMode = iota
+       // originCandidate means the origin advertised HTTP/3 and is waiting 
for validation.
+       originCandidate
+       // originProbing means an out-of-band HTTP/3 probe is in flight.
+       originProbing
+       // originH3Healthy means later requests may be sent over HTTP/3.
+       originH3Healthy
+       // originCooldown means HTTP/3 recently failed and should be avoided 
for a while.
+       originCooldown
+)
+
+const (
+       defaultH3ProbeTimeout = 3 * time.Second
+       defaultH3BaseCooldown = 4 * time.Second
+       defaultH3MaxCooldown  = 1 * time.Minute
+)
+
+// originState tracks whether the current upstream origin is ready for HTTP/3.
+type originState struct {
+       mode          originMode
+       failures      int
+       cooldownUntil time.Time
+}
+
+// dualTransport keeps HTTP/2 as the stable path and only uses HTTP/3 after 
discovery and probe.
+type dualTransport struct {

Review Comment:
   in the current client wiring, one dualTransport is created for one 
clientManager / tri.Client and is effectively bound to one fixed upstream 
origin.   The Alt-Svc cache is host-keyed because Alt-Svc itself is 
host-scoped. So the cache being per-host is still correct even under the 
current single-origin transport usage.



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