MCPcopy Create free account
hub / github.com/PostHog/duckgres / HandlePeerGet

Method HandlePeerGet

cmd/cache-proxy/proxy.go:789–805  ·  view source on GitHub ↗

HandlePeerGet returns cached data to a peer.

(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

787
788// originErrorBodyCap is the maximum number of bytes we'll buffer from a
789// non-2xx origin response. S3 XML error envelopes are tiny; this is just a
790// safety net.
791const originErrorBodyCap = 1 << 20 // 1 MiB
792
793// originStatusError captures a non-2xx response from the origin so the
794// proxy can forward it back to the client verbatim. The status code, body,
795// and response headers are all preserved (minus hop-by-hop) so DuckDB sees
796// exactly what S3 said — including the XML error envelope DuckLake may
797// inspect.
798type originStatusError struct {
799 status int
800 headers http.Header
801 body []byte
802}
803
804func (e *originStatusError) Error() string {
805 return fmt.Sprintf("origin %d: %s", e.status, strings.TrimSpace(string(e.body)))
806}
807
808// writeTo replays the captured origin response onto w. Any header the origin

Callers 2

TestHandlePeerHasAndGetFunction · 0.80

Calls 7

IsValidCacheKeyFunction · 0.85
QueryMethod · 0.65
CloseMethod · 0.65
GetMethod · 0.45
ErrorMethod · 0.45
OpenMethod · 0.45
HeaderMethod · 0.45

Tested by 2

TestHandlePeerHasAndGetFunction · 0.64