MCPcopy Create free account
hub / github.com/cortexproject/cortex / concurrency

Method concurrency

pkg/querier/worker/processor_manager.go:59–84  ·  view source on GitHub ↗
(n int)

Source from the content-addressed store, hash-verified

57}
58
59func (pm *processorManager) concurrency(n int) {
60 pm.cancelsMu.Lock()
61 defer pm.cancelsMu.Unlock()
62
63 if n < 0 {
64 n = 0
65 }
66
67 for len(pm.cancels) < n {
68 ctx, cancel := context.WithCancel(pm.ctx)
69 pm.cancels = append(pm.cancels, cancel)
70
71 pm.wg.Go(func() {
72
73 pm.currentProcessors.Inc()
74 defer pm.currentProcessors.Dec()
75
76 pm.p.processQueriesOnSingleStream(ctx, pm.conn, pm.address)
77 })
78 }
79
80 for len(pm.cancels) > n {
81 pm.cancels[0]()
82 pm.cancels = pm.cancels[1:]
83 }
84}

Callers 3

stopMethod · 0.95
resetConcurrencyMethod · 0.80

Calls 3

DecMethod · 0.80
IncMethod · 0.45

Tested by 1