feat: add per-channel HTTP transport controls

This commit is contained in:
CaIon
2026-07-27 21:41:13 +08:00
parent b27b2b1d6f
commit e99a9bd86f
24 changed files with 1330 additions and 81 deletions
+3
View File
@@ -954,6 +954,9 @@ func (channel *Channel) ValidateSettings() error {
if _, err := common.ParseProxyURLStrict(channelParams.Proxy); err != nil {
return fmt.Errorf("invalid channel proxy: %w", err)
}
if err := channelParams.ValidateHTTPTransport(); err != nil {
return err
}
channelOtherSettings := &dto.ChannelOtherSettings{}
if channel.OtherSettings != "" {
err := common.UnmarshalJsonStr(channel.OtherSettings, channelOtherSettings)
+32
View File
@@ -9,6 +9,38 @@ import (
"github.com/stretchr/testify/require"
)
func TestChannelValidateSettingsRejectsInvalidHTTPTransport(t *testing.T) {
tests := []struct {
name string
setting dto.ChannelSettings
wantErr string
}{
{
name: "auto with shards is valid",
setting: dto.ChannelSettings{HTTPProtocol: "auto", HTTP2ConnectionShards: 4},
},
{
name: "http1 with shards greater than one rejected",
setting: dto.ChannelSettings{HTTPProtocol: "http1", HTTP2ConnectionShards: 2},
wantErr: "http2_connection_shards",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
channel := &Channel{}
channel.SetSetting(tt.setting)
err := channel.ValidateSettings()
if tt.wantErr == "" {
require.NoError(t, err)
return
}
require.Error(t, err)
assert.Contains(t, err.Error(), tt.wantErr)
})
}
}
func TestAdvancedCustomChannelRequiresModelListRouteOnlyWhenUpdateChecksEnabled(t *testing.T) {
inferenceRoute := dto.AdvancedCustomRoute{
IncomingPath: "/v1/chat/completions",