Documentation
¶
Overview ¶
Package sideband validates a Git protocol v2 upload-pack response stream.
Packhorse used to cache upload-pack responses based only on the HTTP status. But an upload-pack failure (for example a pack-objects concurrency-queue timeout in Gitaly) is delivered in-band on an already-200 response: the header is sent before upload-pack runs, so the failure arrives as a sideband band-3 error and/or a truncated packfile. Caching that response pins a transient failure and replays it to every later retry with the same cache key.
Validator inspects the response as it streams past, without buffering the whole (multi-gigabyte) packfile, and reports whether the stream completed cleanly. Callers place it in an io.MultiWriter alongside the client and cache writers, then commit the cache entry only if Err returns nil.
Protocol shape ¶
A protocol v2 fetch response is a pkt-line stream. Optional sections (acknowledgments, shallow-info, wanted-refs, packfile-uris) precede the packfile section, separated by delim-pkts. The packfile section begins with a "packfile" header pkt-line; in protocol v2 its body is ALWAYS sideband- multiplexed, so each following pkt-line is one band byte plus data: band 1 = pack data, band 2 = progress, band 3 = fatal error. The whole response ends with a flush-pkt.
Validator flags a response as unusable if:
- a top-level "ERR <msg>" pkt-line appears (failure during negotiation), or
- a band-3 pkt-line appears in the packfile section (upstream aborted), or
- there is no packfile section, or
- the stream does not terminate with a flush-pkt after the packfile section (truncation, exactly what a failed pack-objects produces).
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInBandFailure means the stream carried a git protocol error even // though the HTTP status was 200: a top-level ERR pkt-line or a sideband // band-3 fatal error. ErrInBandFailure = errors.New("upstream git response contained an in-band error") // ErrTruncated means the stream was cut short or malformed: it did not end // with a flush-pkt after the packfile section, or a pkt-line length could // not be parsed. ErrTruncated = errors.New("upstream git response was truncated or malformed") // ErrNoPackfile means the stream ended cleanly but never contained a // packfile section, so there is nothing worth caching. ErrNoPackfile = errors.New("upstream git response contained no packfile section") )
Functions ¶
This section is empty.
Types ¶
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
Validator scans a git upload-pack response stream and records whether it completed cleanly. It is not safe for concurrent use.
func NewValidator ¶
func NewValidator() *Validator
NewValidator returns a Validator ready to receive the response stream.