Skip to content

Feat: Add Experimental Triple HTTP/3 Support #2916

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 35 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
659d91d
start triple http3 server successfully!
marsevilspirit Jun 15, 2025
8df7d04
add http3 config for triple protocol
marsevilspirit Jun 15, 2025
df0e3d6
rename URL to url
marsevilspirit Jun 15, 2025
65b89f2
fix v1.33.0 of google.golang.org/protobuf Fails to Compile
marsevilspirit Jun 15, 2025
02da3d8
triple http3 client start successfully!
marsevilspirit Jun 15, 2025
ef14aac
add some comments
marsevilspirit Jun 15, 2025
ac3936b
update triple server run logic
marsevilspirit Jun 15, 2025
91389cc
optimize http type
marsevilspirit Jun 15, 2025
8ee1176
make triple http3 support keepalive option
marsevilspirit Jun 15, 2025
a9d9efa
add http2 keepalive config with tls
marsevilspirit Jun 15, 2025
4d68ccc
rename genKeepAliveOptions
marsevilspirit Jun 16, 2025
9d21484
add some todo
marsevilspirit Jun 16, 2025
c390d68
opitmize tlsConf params
marsevilspirit Jun 16, 2025
175ad61
fix http protocol bug
marsevilspirit Jun 16, 2025
1313e04
rename callProtocol
marsevilspirit Jun 16, 2025
596758b
add some comments about http3 config
marsevilspirit Jun 16, 2025
1aef30b
make panic when triple http3 server's TLS config is nil.
marsevilspirit Jun 16, 2025
223f3d1
fix typo
marsevilspirit Jun 16, 2025
7b58d74
opitmize config code
marsevilspirit Jun 16, 2025
839d6e7
add experimental warning for http3 api
marsevilspirit Jun 16, 2025
0bad259
add some todo
marsevilspirit Jun 16, 2025
7ecec8f
support instance and yaml start with http3
marsevilspirit Jun 16, 2025
49202c7
enable http3 gracefulstop
marsevilspirit Jun 17, 2025
1a77738
opitmize callprotocol usage
marsevilspirit Jun 17, 2025
ef3bfd9
rename ProtocolClientConfig to ClientProtocolConfig
marsevilspirit Jun 17, 2025
0e57b92
replace panic with return error
marsevilspirit Jun 17, 2025
0b4d363
optimize logger output
marsevilspirit Jun 17, 2025
9a82631
optimize parser error
marsevilspirit Jun 17, 2025
fee50c2
add some comments
marsevilspirit Jun 17, 2025
edfa8d9
add config unit tests
marsevilspirit Jun 17, 2025
c937f20
Use a WaitGroup to manage the concurrent shutdown of goroutines effec…
marsevilspirit Jun 17, 2025
f1ad8ca
fix typo and add config unit test
marsevilspirit Jun 17, 2025
3917584
Merge branch 'main' into feat/triple-http3
marsevilspirit Jun 25, 2025
1a30dcb
use switch to handle error
marsevilspirit Jun 25, 2025
1c4c164
Merge branch 'develop' into feat/triple-http3
marsevilspirit Jun 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ func WithClientProtocol(opts ...protocol.ClientOption) ClientOption {

return func(srvOpts *ClientOptions) {
if srvOpts.overallReference.ProtocolClientConfig == nil {
srvOpts.overallReference.ProtocolClientConfig = new(global.ProtocolClientConfig)
srvOpts.overallReference.ProtocolClientConfig = new(global.ClientProtocolConfig)
}
srvOpts.overallReference.ProtocolClientConfig = proOpts.ProtocolClient
}
Expand Down
2 changes: 1 addition & 1 deletion common/constant/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ const (
CallClientStream = "client-stream"
CallServerStream = "server-stream"
CallBidiStream = "bidi-stream"
CallHTTPTypeKey = "call-http-type"
CallHTTP = "http"
CallHTTP2 = "http2"
CallHTTP3 = "http3"
ServiceInfoKey = "service-info"
RpcServiceKey = "rpc-service"
ClientInfoKey = "client-info"
Expand Down
157 changes: 131 additions & 26 deletions compat.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,22 @@ func compatTripleConfig(c *global.TripleConfig) *config.TripleConfig {
return nil
}
return &config.TripleConfig{
KeepAliveInterval: c.KeepAliveInterval,
KeepAliveTimeout: c.KeepAliveTimeout,
MaxServerSendMsgSize: c.MaxServerSendMsgSize,
MaxServerRecvMsgSize: c.MaxServerRecvMsgSize,
Http3: compatHttp3Config(c.Http3),

KeepAliveInterval: c.KeepAliveInterval,
KeepAliveTimeout: c.KeepAliveTimeout,
}
}

// just for compat
func compatHttp3Config(c *global.Http3Config) *config.Http3Config {
if c == nil {
return nil
}
return &config.Http3Config{
Enable: c.Enable,
}
}

Expand Down Expand Up @@ -276,6 +288,73 @@ func compatConsumerConfig(c *global.ConsumerConfig) *config.ConsumerConfig {
FilterConf: c.FilterConf,
MaxWaitTimeForServiceDiscovery: c.MaxWaitTimeForServiceDiscovery,
MeshEnabled: c.MeshEnabled,
References: compatReferences(c.References),
}
}

func compatReferences(c map[string]*global.ReferenceConfig) map[string]*config.ReferenceConfig {
refs := make(map[string]*config.ReferenceConfig, len(c))
for name, ref := range c {
refs[name] = &config.ReferenceConfig{
InterfaceName: ref.InterfaceName,
Check: ref.Check,
URL: ref.URL,
Filter: ref.Filter,
Protocol: ref.Protocol,
RegistryIDs: ref.RegistryIDs,
Cluster: ref.Cluster,
Loadbalance: ref.Loadbalance,
Retries: ref.Retries,
Group: ref.Group,
Version: ref.Version,
Serialization: ref.Serialization,
ProvidedBy: ref.ProvidedBy,
MethodsConfig: compatMethod(ref.MethodsConfig),
ProtocolClientConfig: compatProtocolClientConfig(ref.ProtocolClientConfig),
Async: ref.Async,
Params: ref.Params,
Generic: ref.Generic,
Sticky: ref.Sticky,
RequestTimeout: ref.RequestTimeout,
ForceTag: ref.ForceTag,
TracingKey: ref.TracingKey,
MeshProviderPort: ref.MeshProviderPort,
}
}
return refs
}

// TODO: merge compatGlobalMethod() and compatGlobalMethodConfig
func compatMethod(m []*global.MethodConfig) []*config.MethodConfig {
methods := make([]*config.MethodConfig, 0, len(m))
for _, method := range m {
methods = append(methods, &config.MethodConfig{
InterfaceId: method.InterfaceId,
InterfaceName: method.InterfaceName,
Name: method.Name,
Retries: method.Retries,
LoadBalance: method.LoadBalance,
Weight: method.Weight,
TpsLimitInterval: method.TpsLimitInterval,
TpsLimitRate: method.TpsLimitRate,
TpsLimitStrategy: method.TpsLimitStrategy,
ExecuteLimit: method.ExecuteLimit,
ExecuteLimitRejectedHandler: method.ExecuteLimitRejectedHandler,
Sticky: method.Sticky,
RequestTimeout: method.RequestTimeout,
})
}
return methods
}

// just for compat
func compatProtocolClientConfig(c *global.ClientProtocolConfig) *config.ClientProtocolConfig {
if c == nil {
return nil
}
return &config.ClientProtocolConfig{
Name: c.Name,
TripleConfig: compatTripleConfig(c.TripleConfig),
}
}

Expand Down Expand Up @@ -422,6 +501,7 @@ func compatInstanceOptions(cr *config.RootConfig, rc *InstanceOptions) {
if cr == nil {
return
}

proCompat := make(map[string]*global.ProtocolConfig)
for k, v := range cr.Protocols {
proCompat[k] = compatGlobalProtocolConfig(v)
Expand Down Expand Up @@ -470,13 +550,25 @@ func compatGlobalTripleConfig(c *config.TripleConfig) *global.TripleConfig {
return nil
}
return &global.TripleConfig{
KeepAliveInterval: c.KeepAliveInterval,
KeepAliveTimeout: c.KeepAliveTimeout,
KeepAliveInterval: c.KeepAliveInterval,
KeepAliveTimeout: c.KeepAliveTimeout,
Http3: compatGlobalHttp3Config(c.Http3),

MaxServerSendMsgSize: c.MaxServerSendMsgSize,
MaxServerRecvMsgSize: c.MaxServerRecvMsgSize,
}
}

// just for compat
func compatGlobalHttp3Config(c *config.Http3Config) *global.Http3Config {
if c == nil {
return nil
}
return &global.Http3Config{
Enable: c.Enable,
}
}

func compatGlobalRegistryConfig(c *config.RegistryConfig) *global.RegistryConfig {
if c == nil {
return nil
Expand Down Expand Up @@ -674,33 +766,35 @@ func compatGlobalReferences(c map[string]*config.ReferenceConfig) map[string]*gl
refs := make(map[string]*global.ReferenceConfig, len(c))
for name, ref := range c {
refs[name] = &global.ReferenceConfig{
InterfaceName: ref.InterfaceName,
Check: ref.Check,
URL: ref.URL,
Filter: ref.Filter,
Protocol: ref.Protocol,
RegistryIDs: ref.RegistryIDs,
Cluster: ref.Cluster,
Loadbalance: ref.Loadbalance,
Retries: ref.Retries,
Group: ref.Group,
Version: ref.Version,
Serialization: ref.Serialization,
ProvidedBy: ref.ProvidedBy,
MethodsConfig: compatGlobalMethod(ref.Methods),
Async: ref.Async,
Params: ref.Params,
Generic: ref.Generic,
Sticky: ref.Sticky,
RequestTimeout: ref.RequestTimeout,
ForceTag: ref.ForceTag,
TracingKey: ref.TracingKey,
MeshProviderPort: ref.MeshProviderPort,
InterfaceName: ref.InterfaceName,
Check: ref.Check,
URL: ref.URL,
Filter: ref.Filter,
Protocol: ref.Protocol,
RegistryIDs: ref.RegistryIDs,
Cluster: ref.Cluster,
Loadbalance: ref.Loadbalance,
Retries: ref.Retries,
Group: ref.Group,
Version: ref.Version,
Serialization: ref.Serialization,
ProvidedBy: ref.ProvidedBy,
MethodsConfig: compatGlobalMethod(ref.MethodsConfig),
ProtocolClientConfig: compatGlobalProtocolClientConfig(ref.ProtocolClientConfig),
Async: ref.Async,
Params: ref.Params,
Generic: ref.Generic,
Sticky: ref.Sticky,
RequestTimeout: ref.RequestTimeout,
ForceTag: ref.ForceTag,
TracingKey: ref.TracingKey,
MeshProviderPort: ref.MeshProviderPort,
}
}
return refs
}

// TODO: merge compatGlobalMethod() and compatGlobalMethodConfig
func compatGlobalMethod(m []*config.MethodConfig) []*global.MethodConfig {
methods := make([]*global.MethodConfig, 0, len(m))
for _, method := range m {
Expand All @@ -723,6 +817,17 @@ func compatGlobalMethod(m []*config.MethodConfig) []*global.MethodConfig {
return methods
}

// just for compat
func compatGlobalProtocolClientConfig(c *config.ClientProtocolConfig) *global.ClientProtocolConfig {
if c == nil {
return nil
}
return &global.ClientProtocolConfig{
Name: c.Name,
TripleConfig: compatGlobalTripleConfig(c.TripleConfig),
}
}

func compatGlobalMetricConfig(c *config.MetricsConfig) *global.MetricsConfig {
if c == nil {
return nil
Expand Down
26 changes: 26 additions & 0 deletions config/client_protocol_config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* 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 config

// ClientProtocolConfig represents the config of client's protocol
type ClientProtocolConfig struct {
// TODO: maybe we could use this field
Name string `yaml:"name" json:"name,omitempty" property:"name"`

TripleConfig *TripleConfig `yaml:"triple" json:"triple,omitempty" property:"triple"`
}
34 changes: 34 additions & 0 deletions config/http3_config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* 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 config

// Http3Config represents the config of http3
type Http3Config struct {
// Whether to enable HTTP/3 support.
// The default value is false.
Enable bool `yaml:"enable" json:"enable,omitempty"`
// TODO: add more params about http3

// TODO: negotiation implementation
// ref: https://quic-go.net/docs/http3/server/#advertising-http3-via-alt-svc
//
// Whether to enable HTTP/3 negotiation.
// If set to false, HTTP/2 alt-svc negotiation will be skipped,
// enabling HTTP/3 but disabling HTTP/2 on the consumer side.
// negotiation bool
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good job

}
44 changes: 24 additions & 20 deletions config/reference_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,25 @@ type ReferenceConfig struct {
urls []*common.URL
rootConfig *RootConfig

id string
InterfaceName string `yaml:"interface" json:"interface,omitempty" property:"interface"`
Check *bool `yaml:"check" json:"check,omitempty" property:"check"`
URL string `yaml:"url" json:"url,omitempty" property:"url"`
Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"`
Protocol string `yaml:"protocol" json:"protocol,omitempty" property:"protocol"`
RegistryIDs []string `yaml:"registry-ids" json:"registry-ids,omitempty" property:"registry-ids"`
Cluster string `yaml:"cluster" json:"cluster,omitempty" property:"cluster"`
Loadbalance string `yaml:"loadbalance" json:"loadbalance,omitempty" property:"loadbalance"`
Retries string `yaml:"retries" json:"retries,omitempty" property:"retries"`
Group string `yaml:"group" json:"group,omitempty" property:"group"`
Version string `yaml:"version" json:"version,omitempty" property:"version"`
Serialization string `yaml:"serialization" json:"serialization" property:"serialization"`
ProvidedBy string `yaml:"provided_by" json:"provided_by,omitempty" property:"provided_by"`
Methods []*MethodConfig `yaml:"methods" json:"methods,omitempty" property:"methods"`
id string
InterfaceName string `yaml:"interface" json:"interface,omitempty" property:"interface"`
Check *bool `yaml:"check" json:"check,omitempty" property:"check"`
URL string `yaml:"url" json:"url,omitempty" property:"url"`
Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"`
Protocol string `yaml:"protocol" json:"protocol,omitempty" property:"protocol"`
RegistryIDs []string `yaml:"registry-ids" json:"registry-ids,omitempty" property:"registry-ids"`
Cluster string `yaml:"cluster" json:"cluster,omitempty" property:"cluster"`
Loadbalance string `yaml:"loadbalance" json:"loadbalance,omitempty" property:"loadbalance"`
Retries string `yaml:"retries" json:"retries,omitempty" property:"retries"`
Group string `yaml:"group" json:"group,omitempty" property:"group"`
Version string `yaml:"version" json:"version,omitempty" property:"version"`
Serialization string `yaml:"serialization" json:"serialization" property:"serialization"`
ProvidedBy string `yaml:"provided_by" json:"provided_by,omitempty" property:"provided_by"`

MethodsConfig []*MethodConfig `yaml:"methods" json:"methods,omitempty" property:"methods"`
// TODO: rename protocol_config to protocol when publish 4.0.0.
ProtocolClientConfig *ClientProtocolConfig `yaml:"protocol_config" json:"protocol_config,omitempty" property:"protocol_config"`

Async bool `yaml:"async" json:"async,omitempty" property:"async"`
Params map[string]string `yaml:"params" json:"params,omitempty" property:"params"`
Generic string `yaml:"generic" json:"generic,omitempty" property:"generic"`
Expand All @@ -84,7 +88,7 @@ func (rc *ReferenceConfig) Prefix() string {
}

func (rc *ReferenceConfig) Init(root *RootConfig) error {
for _, method := range rc.Methods {
for _, method := range rc.MethodsConfig {
if err := method.Init(); err != nil {
return err
}
Expand Down Expand Up @@ -364,7 +368,7 @@ func (rc *ReferenceConfig) getURLMap() url.Values {
}
urlMap.Set(constant.ReferenceFilterKey, mergeValue(rc.Filter, "", defaultReferenceFilter))

for _, v := range rc.Methods {
for _, v := range rc.MethodsConfig {
urlMap.Set("methods."+v.Name+"."+constant.LoadbalanceKey, v.LoadBalance)
urlMap.Set("methods."+v.Name+"."+constant.RetriesKey, v.Retries)
urlMap.Set("methods."+v.Name+"."+constant.StickyKey, strconv.FormatBool(v.Sticky))
Expand Down Expand Up @@ -402,7 +406,7 @@ func (rc *ReferenceConfig) postProcessConfig(url *common.URL) {
// newEmptyReferenceConfig returns empty ReferenceConfig
func newEmptyReferenceConfig() *ReferenceConfig {
newReferenceConfig := &ReferenceConfig{}
newReferenceConfig.Methods = make([]*MethodConfig, 0, 8)
newReferenceConfig.MethodsConfig = make([]*MethodConfig, 0, 8)
newReferenceConfig.Params = make(map[string]string, 8)
return newReferenceConfig
}
Expand Down Expand Up @@ -485,12 +489,12 @@ func (pcb *ReferenceConfigBuilder) SetProvidedBy(providedBy string) *ReferenceCo
}

func (pcb *ReferenceConfigBuilder) SetMethodConfig(methodConfigs []*MethodConfig) *ReferenceConfigBuilder {
pcb.referenceConfig.Methods = methodConfigs
pcb.referenceConfig.MethodsConfig = methodConfigs
return pcb
}

func (pcb *ReferenceConfigBuilder) AddMethodConfig(methodConfig *MethodConfig) *ReferenceConfigBuilder {
pcb.referenceConfig.Methods = append(pcb.referenceConfig.Methods, methodConfig)
pcb.referenceConfig.MethodsConfig = append(pcb.referenceConfig.MethodsConfig, methodConfig)
return pcb
}

Expand Down
12 changes: 8 additions & 4 deletions config/triple_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@

package config

// TripleConfig represents the config of triple protocol
type TripleConfig struct {
KeepAliveInterval string `yaml:"keep-alive-interval" json:"keep-alive-interval,omitempty" property:"keep-alive-interval"`
KeepAliveTimeout string `yaml:"keep-alive-timeout" json:"keep-alive-timeout,omitempty" property:"keep-alive-timeout"`

// MaxServerSendMsgSize max size of server send message, 1mb=1000kb=1000000b 1mib=1024kb=1048576b.
// more detail to see https://pkg.go.dev/github.com/dustin/go-humanize#pkg-constants
MaxServerSendMsgSize string `yaml:"max-server-send-msg-size" json:"max-server-send-msg-size,omitempty"` // MaxServerRecvMsgSize max size of server receive message
MaxServerSendMsgSize string `yaml:"max-server-send-msg-size" json:"max-server-send-msg-size,omitempty"`
// MaxServerRecvMsgSize max size of server receive message
MaxServerRecvMsgSize string `yaml:"max-server-recv-msg-size" json:"max-server-recv-msg-size,omitempty"`

Http3 *Http3Config `yaml:"http3" json:"http3,omitempty" property:"http3"`

KeepAliveInterval string `yaml:"keep-alive-interval" json:"keep-alive-interval,omitempty" property:"keep-alive-interval"`
KeepAliveTimeout string `yaml:"keep-alive-timeout" json:"keep-alive-timeout,omitempty" property:"keep-alive-timeout"`
}
Loading
Loading