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

Method acquireWorker

handlers/processing/request_methods.go:31–50  ·  view source on GitHub ↗

acquireWorker acquires the processing worker

()

Source from the content-addressed store, hash-verified

29
30// acquireWorker acquires the processing worker
31func (r *request) acquireWorker() (context.CancelFunc, errctx.Error) {
32 ctx, cancelSpan := r.Monitoring().StartSpan(r.req.Context(), "Queue", nil)
33 defer cancelSpan()
34
35 fn, err := r.Workers().Acquire(ctx)
36 if err != nil {
37 // We don't actually need to check timeout here,
38 // but it's an easy way to check if this is an actual timeout
39 // or the request was canceled
40 if terr := server.CheckTimeout(ctx); terr != nil {
41 return nil, terr
42 }
43
44 // We should never reach this line as err could be only ctx.Err()
45 // and we've already checked for it. But beter safe than sorry
46 return nil, errctx.Wrap(err)
47 }
48
49 return fn, nil
50}
51
52// makeDownloadOptions creates a new default download options
53func (r *request) makeDownloadOptions(

Callers 1

executeMethod · 0.95

Calls 6

CheckTimeoutFunction · 0.92
WrapFunction · 0.92
AcquireMethod · 0.80
StartSpanMethod · 0.65
MonitoringMethod · 0.65
WorkersMethod · 0.65

Tested by

no test coverage detected