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 = 4 * 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 (e.g. satellite) where even this trips before the node answers.
const DefaultDiscoveryDialTimeout = 10 * time.Second
DefaultDiscoveryDialTimeout is the per-host TCP connect budget for the initial replica-discovery request — the cold info/refs probe to the cluster entry domain that answers "which nodes serve this repo". It is deliberately longer than DefaultDialTimeout: this first contact often pays a cold DNS + TLS handshake to a possibly-distant entry LB, and unlike replica failover there is no second node to roll to, so tripping here fails the whole clone/fetch. Replica failover keeps the short DefaultDialTimeout so dead nodes are still skipped quickly.
An explicit ENTIRE_CONNECT_TIMEOUT_SECONDS overrides this too: a user who sets it gets that one value for every connect, discovery included.
const EnvConnectTimeout = "ENTIRE_CONNECT_TIMEOUT_SECONDS"
EnvConnectTimeout is the env var that overrides every connect timeout.
Variables ¶
This section is empty.
Functions ¶
func DialTimeout ¶
DialTimeout returns the connect timeout for ordinary requests (and replica failover): the ENTIRE_CONNECT_TIMEOUT_SECONDS override if set, else DefaultDialTimeout.
func DiscoveryDialTimeout ¶ added in v0.7.8
DiscoveryDialTimeout returns the connect budget for the discovery probe. When ENTIRE_CONNECT_TIMEOUT_SECONDS is set it wins outright (the user's chosen value applies to every connect); otherwise it falls back to the more patient DefaultDiscoveryDialTimeout rather than DefaultDialTimeout.
func NewDiscoveryTransport ¶ added in v0.7.8
NewDiscoveryTransport is NewTransport with the longer discovery connect budget (DiscoveryDialTimeout). Use it for the initial replica-discovery probe; see DefaultDiscoveryDialTimeout for why it is more patient.
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.