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

Method HandlePeerHas

cmd/cache-proxy/proxy.go:775–786  ·  view source on GitHub ↗

HandlePeerHas responds to "do you have this cache key?" from peers.

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

Source from the content-addressed store, hash-verified

773 msg := strings.ToLower(err.Error())
774 switch {
775 case strings.Contains(msg, "connection reset by peer"):
776 return "connection_reset"
777 case strings.Contains(msg, "connection refused"):
778 return "connection_refused"
779 case strings.Contains(msg, "unexpected eof"):
780 return "unexpected_eof"
781 case strings.Contains(msg, "timeout"):
782 return "timeout"
783 default:
784 return "transport_error"
785 }
786}
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

Callers 2

TestHandlePeerHasAndGetFunction · 0.80

Calls 5

IsValidCacheKeyFunction · 0.85
HasMethod · 0.80
QueryMethod · 0.65
GetMethod · 0.45
ErrorMethod · 0.45

Tested by 2

TestHandlePeerHasAndGetFunction · 0.64