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

Method forwardUncached

cmd/cache-proxy/proxy.go:702–772  ·  view source on GitHub ↗

forwardUncached forwards a request to the origin without caching. Used for HEAD and other non-GET methods that shouldn't consume cache space. Logs symmetrically with HandleProxy's GET path so a non-2xx PUT/POST (e.g. an S3 501 on a parquet write) is visible in Loki — without this, the non-cached pa

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

Source from the content-addressed store, hash-verified

700 case <-timer.C:
701 return true
702 }
703}
704
705func isRetriableOriginFetchError(err error) bool {
706 if err == nil {
707 return false
708 }
709 var oe *originStatusError
710 if errors.As(err, &oe) {
711 switch oe.status {
712 case http.StatusRequestTimeout,
713 http.StatusTooManyRequests,
714 http.StatusInternalServerError,
715 http.StatusBadGateway,
716 http.StatusServiceUnavailable,
717 http.StatusGatewayTimeout:
718 return true
719 default:
720 return false
721 }
722 }
723 if errors.Is(err, context.Canceled) {
724 return false
725 }
726 if errors.Is(err, context.DeadlineExceeded) {
727 return true
728 }
729 var netErr net.Error
730 if errors.As(err, &netErr) && netErr.Timeout() {
731 return true
732 }
733 msg := strings.ToLower(err.Error())
734 return strings.Contains(msg, "connection reset by peer") ||
735 strings.Contains(msg, "connection refused") ||
736 strings.Contains(msg, "unexpected eof") ||
737 strings.Contains(msg, "timeout")
738}
739
740func originFetchOutcome(err error) string {
741 if err == nil {
742 return "success"
743 }
744 var oe *originStatusError
745 if errors.As(err, &oe) {
746 return "http_error"
747 }
748 if errors.Is(err, context.Canceled) {
749 return "canceled"
750 }
751 if errors.Is(err, context.DeadlineExceeded) {
752 return "timeout"
753 }
754 var netErr net.Error
755 if errors.As(err, &netErr) && netErr.Timeout() {
756 return "timeout"
757 }
758 return "error"
759}

Callers 1

HandleProxyMethod · 0.95

Calls 11

requestSpanAttrsFunction · 0.85
previewBodyFunction · 0.85
AddMethod · 0.80
DoMethod · 0.80
CloseMethod · 0.65
StartMethod · 0.45
ContextMethod · 0.45
StringMethod · 0.45
ErrorMethod · 0.45
HeaderMethod · 0.45
WriteMethod · 0.45

Tested by

no test coverage detected