perf(cmpp): isolate inbound transport capacity

This commit is contained in:
hectorzhao
2026-08-20 18:09:29 +08:00
parent 53073461e9
commit 6708f1f7c5
11 changed files with 95 additions and 8 deletions
@@ -0,0 +1,28 @@
package inbound
import (
"net/http"
"testing"
)
func TestNewAPIHTTPClientMatchesBoundedSubmitConcurrency(t *testing.T) {
client := NewAPIHTTPClient(48)
transport, ok := client.Transport.(*http.Transport)
if !ok {
t.Fatalf("expected *http.Transport, got %T", client.Transport)
}
if transport.MaxConnsPerHost != 48 || transport.MaxIdleConnsPerHost != 48 {
t.Fatalf("unexpected host connection bounds: max=%d idle=%d", transport.MaxConnsPerHost, transport.MaxIdleConnsPerHost)
}
if client.Timeout != defaultHTTPTimeout {
t.Fatalf("unexpected client timeout: %s", client.Timeout)
}
}
func TestNewAPIHTTPClientUsesSafeDefault(t *testing.T) {
client := NewAPIHTTPClient(0)
transport := client.Transport.(*http.Transport)
if transport.MaxConnsPerHost != 64 {
t.Fatalf("expected default max connections 64, got %d", transport.MaxConnsPerHost)
}
}