MCPcopy Index your code
hub / github.com/ContentSquare/chproxy / completeTransaction

Method completeTransaction

proxy.go:585–606  ·  view source on GitHub ↗
(s *scope, statusCode int, userCache *cache.AsyncCache, key *cache.Key,
	q []byte,
	failReason string,
)

Source from the content-addressed store, hash-verified

583var clickhouseRecoverableStatusCodes = map[int]struct{}{http.StatusServiceUnavailable: {}, http.StatusRequestTimeout: {}}
584
585func (rp *reverseProxy) completeTransaction(s *scope, statusCode int, userCache *cache.AsyncCache, key *cache.Key,
586 q []byte,
587 failReason string,
588) {
589 // complete successful transactions or those with empty fail reason
590 if statusCode < 300 || failReason == "" {
591 if err := userCache.Complete(key); err != nil {
592 log.Errorf("%s: %s; query: %q", s, err, q)
593 }
594 return
595 }
596
597 if _, ok := clickhouseRecoverableStatusCodes[statusCode]; ok {
598 if err := userCache.Complete(key); err != nil {
599 log.Errorf("%s: %s; query: %q", s, err, q)
600 }
601 } else {
602 if err := userCache.Fail(key, failReason); err != nil {
603 log.Errorf("%s: %s; query: %q", s, err, q)
604 }
605 }
606}
607
608func calcQueryParamsHash(origParams url.Values) uint32 {
609 queryParams := make(map[string]string)

Callers 1

serveFromCacheMethod · 0.95

Calls 3

ErrorfFunction · 0.92
CompleteMethod · 0.65
FailMethod · 0.65

Tested by

no test coverage detected