Documentation
¶
Overview ¶
server.go —— agentd 测试 HTTP fixture 的 TCP 连接收口与 loopback 拨号重试。
职责:包装 httptest 的服务端 Accept 与测试 client 的 DialContext,使临时端口 在 Darwin 上更快释放,并把极窄的 EADDRNOTAVAIL 重试限制在测试 fixture。 边界:本包只供测试导入;不修改生产 client.New、不重试 Client.Do;非 loopback 地址与非指定错误都只尝试一次。
Index ¶
Constants ¶
const (
// MaxDialAttempts bounds retries for a single loopback address-allocation failure.
MaxDialAttempts = 4
)
Variables ¶
This section is empty.
Functions ¶
func CloseIdleConnections ¶
func CloseIdleConnections()
CloseIdleConnections closes tracked idle transports and the standard default transport. It is intentionally separate from request cancellation.
func ConfigureClient ¶
ConfigureClient replaces only a *http.Transport's dial hooks. A nil Transport is cloned from http.DefaultTransport so the process-global default is never mutated; a non-*http.Transport is intentionally left unchanged because it has no safe TCP hook.
func NewServer ¶
NewServer starts a linger-enabled httptest server, configures the default client and registers cleanup that closes the server before tracked idle transports.
func NewUnstartedServer ¶
NewUnstartedServer returns a linger-enabled server whose caller may replace Listener or modify Config before Start. The caller must call ConfigureClient(ts.Client()) after Start because httptest creates its client inside Start.
Types ¶
type DialContext ¶
DialContext is the context-aware dial signature wrapped by the fixture.
func RetryDialContext ¶
func RetryDialContext(base DialContext) DialContext
RetryDialContext retries only the two Darwin loopback address-allocation errors and only up to MaxDialAttempts. A successful loopback connection gets client-side linger.