Documentation
¶
Overview ¶
Package upstream records one entry per attempted upstream mirror so a fetch that failed across every mirror can be logged with each mirror's own error. Retry loops used to keep a single lastErr variable, which meant a mirror's TLS or DNS failure was silently replaced by the next mirror's plain 404.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SanitizeURL ¶
SanitizeURL removes any userinfo component. An unparseable URL is returned unchanged: it came from configuration, and hiding it entirely would be worse than logging it verbatim.
Types ¶
type Attempt ¶
Attempt is one mirror's outcome. Status is the upstream HTTP status, or 0 when the request never produced a response at all (TLS verification, DNS, connection refused, timeout, an open circuit breaker). That distinction is the reason this type exists: a 0 and a 404 mean very different things to an operator, and collapsing them hides misconfigured mirrors.
type Attempts ¶
type Attempts []Attempt
Attempts is the ordered list of mirror outcomes for one logical fetch. It implements error, so a retry loop can return it directly, and zerolog.LogArrayMarshaler, so a log site can render every attempt as one structured array field.
func AttemptsFrom ¶
AttemptsFrom recovers the attempts from err, including when err wraps them. Log sites use it to attach the structured array to an error they did not produce themselves.
func (*Attempts) Add ¶
Add appends one outcome. Credentials embedded in rawURL are stripped from the resulting URL field only. err's own text is not sanitised: it is the caller's responsibility. In practice net/http masks a *url.Error's password but leaves the username, and http.NewRequestWithContext on a malformed URL returns the raw URL unmasked.
func (Attempts) AllNotFound ¶
AllNotFound reports whether every mirror answered 404 or 410 — the condition under which the proxy returns 404 rather than 502. An empty list is false: nothing was tried, so nothing proved the artifact absent.
func (Attempts) Error ¶
Error renders every attempt, so the flat message of a wrapped error still carries all mirrors even where the structured array is unavailable.
func (Attempts) MarshalZerologArray ¶
MarshalZerologArray renders the attempts as an array of objects.