MCPcopy Index your code
hub / github.com/cortexlabs/cortex / Handler

Function Handler

pkg/proxy/handler.go:30–48  ·  view source on GitHub ↗
(breaker *Breaker, next http.Handler)

Source from the content-addressed store, hash-verified

28)
29
30func Handler(breaker *Breaker, next http.Handler) http.HandlerFunc {
31 return func(w http.ResponseWriter, r *http.Request) {
32 if probe.IsRequestKubeletProbe(r) || breaker == nil {
33 next.ServeHTTP(w, r)
34 return
35 }
36
37 if err := breaker.Maybe(r.Context(), func() {
38 next.ServeHTTP(w, r)
39 }); err != nil {
40 if errors.Is(err, context.DeadlineExceeded) || errors.Is(err, ErrRequestQueueFull) {
41 http.Error(w, err.Error(), http.StatusServiceUnavailable)
42 } else {
43 w.WriteHeader(http.StatusInternalServerError)
44 telemetry.Error(err)
45 }
46 }
47 }
48}

Callers 3

mainFunction · 0.92

Calls 5

IsRequestKubeletProbeFunction · 0.92
ErrorFunction · 0.92
MaybeMethod · 0.80
ErrorMethod · 0.80
ServeHTTPMethod · 0.45

Tested by 2