This is an automated email from the ASF dual-hosted git repository.

Alanxtl pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git


The following commit(s) were added to refs/heads/develop by this push:
     new fcb2e5d4b feat(triple): add HTTP/3 transport options (#3681)
fcb2e5d4b is described below

commit fcb2e5d4bdab1661737a0c69bf6be53dc2fb52a3
Author: CAICAII <[email protected]>
AuthorDate: Wed Aug 19 11:46:07 2026 +0800

    feat(triple): add HTTP/3 transport options (#3681)
    
    * feat(triple): add http3 transport options
    
    Signed-off-by: CAICAIIs <[email protected]>
    
    * refactor(triple): use with-style http3 options
    
    Signed-off-by: CAICAIIs <[email protected]>
    
    * refactor(triple): deprecate legacy http3 option aliases
    
    Signed-off-by: CAICAIIs <[email protected]>
    
    ---------
    
    Signed-off-by: CAICAIIs <[email protected]>
---
 protocol/triple/options.go      | 60 +++++++++++++++++++++++++++++++++------
 protocol/triple/options_test.go | 62 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 113 insertions(+), 9 deletions(-)

diff --git a/protocol/triple/options.go b/protocol/triple/options.go
index 6ebac0759..9e1aa9276 100644
--- a/protocol/triple/options.go
+++ b/protocol/triple/options.go
@@ -118,7 +118,7 @@ func WithCORS(opts ...CORSOption) Option {
        }
 }
 
-// Http3Enable enables HTTP/3 support for the Triple protocol.
+// WithHttp3Enable enables HTTP/3 support for the Triple protocol.
 // This option configures the server to start both HTTP/2 and HTTP/3 servers
 // simultaneously, providing modern HTTP/3 capabilities alongside traditional 
HTTP/2.
 //
@@ -132,7 +132,7 @@ func WithCORS(opts ...CORSOption) Option {
 //
 //     // Basic HTTP/3 enablement
 //     server := triple.NewServer(
-//         triple.Http3Enable(),
+//         triple.WithHttp3Enable(),
 //     )
 //
 // Requirements:
@@ -150,13 +150,20 @@ func WithCORS(opts ...CORSOption) Option {
 //
 // NOTICE: This API is EXPERIMENTAL and may be changed or removed in
 // a later release.
-func Http3Enable() Option {
+func WithHttp3Enable() Option {
        return func(opts *Options) {
                opts.Triple.Http3.Enable = true
        }
 }
 
-// Http3Negotiation configures HTTP/3 negotiation behavior for the Triple 
protocol.
+// Http3Enable enables HTTP/3 support for the Triple protocol.
+//
+// Deprecated: use WithHttp3Enable instead.
+func Http3Enable() Option {
+       return WithHttp3Enable()
+}
+
+// WithHttp3Negotiation configures HTTP/3 negotiation behavior for the Triple 
protocol.
 // This option controls whether HTTP/2 Alternative Services (Alt-Svc) 
negotiation
 // is enabled when both HTTP/2 and HTTP/3 servers are running simultaneously.
 //
@@ -164,14 +171,14 @@ func Http3Enable() Option {
 //
 //     // Enable HTTP/3 negotiation (default behavior)
 //     server := triple.NewServer(
-//         triple.Http3Enable(),
-//         triple.Http3Negotiation(true),
+//         triple.WithHttp3Enable(),
+//         triple.WithHttp3Negotiation(true),
 //     )
 //
 //     // Disable HTTP/3 negotiation for explicit protocol control
 //     server := triple.NewServer(
-//         triple.Http3Enable(),
-//         triple.Http3Negotiation(false),
+//         triple.WithHttp3Enable(),
+//         triple.WithHttp3Negotiation(false),
 //     )
 //
 // Default Behavior:
@@ -182,12 +189,47 @@ func Http3Enable() Option {
 //
 // NOTICE: This API is EXPERIMENTAL and may be changed or removed in
 // a later release.
-func Http3Negotiation(negotiation bool) Option {
+func WithHttp3Negotiation(negotiation bool) Option {
        return func(opts *Options) {
                opts.Triple.Http3.Negotiation = negotiation
        }
 }
 
+// Http3Negotiation configures HTTP/3 negotiation behavior for the Triple 
protocol.
+//
+// Deprecated: use WithHttp3Negotiation instead.
+func Http3Negotiation(negotiation bool) Option {
+       return WithHttp3Negotiation(negotiation)
+}
+
+// WithHttp3KeepAlivePeriod sets how often the HTTP/3 transport sends QUIC 
keep-alive packets.
+func WithHttp3KeepAlivePeriod(period time.Duration) Option {
+       return func(opts *Options) {
+               opts.Triple.Http3.KeepAlivePeriod = period.String()
+       }
+}
+
+// WithHttp3MaxIdleTimeout sets the maximum idle timeout for HTTP/3 QUIC 
connections.
+func WithHttp3MaxIdleTimeout(timeout time.Duration) Option {
+       return func(opts *Options) {
+               opts.Triple.Http3.MaxIdleTimeout = timeout.String()
+       }
+}
+
+// WithHttp3MaxIncomingStreams sets the maximum number of concurrent HTTP/3 
bidirectional streams.
+func WithHttp3MaxIncomingStreams(streams int64) Option {
+       return func(opts *Options) {
+               opts.Triple.Http3.MaxIncomingStreams = streams
+       }
+}
+
+// WithHttp3MaxIncomingUniStreams sets the maximum number of concurrent HTTP/3 
unidirectional streams.
+func WithHttp3MaxIncomingUniStreams(streams int64) Option {
+       return func(opts *Options) {
+               opts.Triple.Http3.MaxIncomingUniStreams = streams
+       }
+}
+
 // CORSOption configures a single aspect of CORS.
 type CORSOption func(*global.CorsConfig)
 
diff --git a/protocol/triple/options_test.go b/protocol/triple/options_test.go
new file mode 100644
index 000000000..61c5f1712
--- /dev/null
+++ b/protocol/triple/options_test.go
@@ -0,0 +1,62 @@
+/*
+ * 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 (
+       "testing"
+       "time"
+)
+
+import (
+       "github.com/stretchr/testify/assert"
+       "github.com/stretchr/testify/require"
+)
+
+func TestHTTP3TransportOptions(t *testing.T) {
+       opts := NewOptions(
+               WithHttp3Enable(),
+               WithHttp3Negotiation(false),
+               WithHttp3KeepAlivePeriod(15*time.Second),
+               WithHttp3MaxIdleTimeout(30*time.Second),
+               WithHttp3MaxIncomingStreams(128),
+               WithHttp3MaxIncomingUniStreams(64),
+       )
+
+       require.NotNil(t, opts)
+       require.NotNil(t, opts.Triple)
+       require.NotNil(t, opts.Triple.Http3)
+       assert.True(t, opts.Triple.Http3.Enable)
+       assert.False(t, opts.Triple.Http3.Negotiation)
+       assert.Equal(t, "15s", opts.Triple.Http3.KeepAlivePeriod)
+       assert.Equal(t, "30s", opts.Triple.Http3.MaxIdleTimeout)
+       assert.Equal(t, int64(128), opts.Triple.Http3.MaxIncomingStreams)
+       assert.Equal(t, int64(64), opts.Triple.Http3.MaxIncomingUniStreams)
+}
+
+func TestHTTP3DeprecatedAliases(t *testing.T) {
+       opts := NewOptions(
+               Http3Enable(),
+               Http3Negotiation(false),
+       )
+
+       require.NotNil(t, opts)
+       require.NotNil(t, opts.Triple)
+       require.NotNil(t, opts.Triple.Http3)
+       assert.True(t, opts.Triple.Http3.Enable)
+       assert.False(t, opts.Triple.Http3.Negotiation)
+}

Reply via email to