MCPcopy Create free account
hub / github.com/imgproxy/imgproxy / CheckTimeout

Function CheckTimeout

server/timer.go:32–49  ·  view source on GitHub ↗

CheckTimeout checks if the request context has timed out or cancelled and returns wrapped error.

(ctx context.Context)

Source from the content-addressed store, hash-verified

30// CheckTimeout checks if the request context has timed out or cancelled and returns
31// wrapped error.
32func CheckTimeout(ctx context.Context) errctx.Error {
33 select {
34 case <-ctx.Done():
35 d := RequestDuration(ctx)
36
37 err := ctx.Err()
38 switch err {
39 case context.Canceled:
40 return newRequestCancelledError(d)
41 case context.DeadlineExceeded:
42 return newRequestTimeoutError(d)
43 default:
44 return errctx.Wrap(err)
45 }
46 default:
47 return nil
48 }
49}

Callers 6

executeMethod · 0.92
acquireWorkerMethod · 0.92
TestCheckTimeoutFunction · 0.92
RunMethod · 0.92
saveImageToFitBytesFunction · 0.92
transformAnimatedMethod · 0.92

Calls 4

WrapFunction · 0.92
RequestDurationFunction · 0.85
newRequestCancelledErrorFunction · 0.85
newRequestTimeoutErrorFunction · 0.70

Tested by 1

TestCheckTimeoutFunction · 0.74