Documentation
¶
Overview ¶
Package httpclient builds *http.Transport instances shared by Entire's client binaries (git-remote-entire, entiredb, entire-deploy). Centralizing transport construction means one place to honor cross-cutting knobs like ENTIRE_CONNECT_TIMEOUT_SECONDS — without forcing callers through a single *http.Client constructor, since they legitimately differ in CheckRedirect, per-client Timeout, and request-level wrapping.
Index ¶
Constants ¶
const DefaultDialTimeout = 2 * time.Second
DefaultDialTimeout is the per-host TCP connect timeout. Short by default so failover paths skip dead nodes quickly, but long enough to absorb a slow initial connect (cold DNS, TLS-fronting LB, distant region) that a tighter budget would trip; override via ENTIRE_CONNECT_TIMEOUT_SECONDS on slow links where even this trips before the node can answer.
Variables ¶
This section is empty.
Functions ¶
func DialTimeout ¶
DialTimeout returns the configured dial timeout, honoring ENTIRE_CONNECT_TIMEOUT_SECONDS. Invalid values fall back to DefaultDialTimeout with a warning to stderr.
func NewTransport ¶
NewTransport builds an *http.Transport with the configured dial timeout and a baseline TLS config. Callers wrap the returned transport with their own RoundTripper as needed (e.g. debug logging) and assemble their own *http.Client around it.
Types ¶
type UserAgentTransport ¶ added in v0.7.4
type UserAgentTransport struct {
Next http.RoundTripper
UA string
}
UserAgentTransport wraps another http.RoundTripper and stamps the User-Agent header on every outgoing request so the server can attribute traffic to the calling binary. Callers that already set User-Agent are overwritten: the wrapper exists to give the binary a single identity in upstream access logs, not to be overridden per request.
The wrapper clones the request before mutating headers so the caller's original *http.Request is left untouched — important for retries and for callers that hold a reference after Do returns.
Concurrent use is safe iff Next is safe for concurrent use.