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

Method getNextQueueForQuerier

pkg/scheduler/queue/user_queues.go:223–255  ·  view source on GitHub ↗

Finds next queue for the querier. To support fair scheduling between users, client is expected to pass last user index returned by this function as argument. Is there was no previous last user index, use -1.

(lastUserIndex int, querierID string)

Source from the content-addressed store, hash-verified

221// to pass last user index returned by this function as argument. Is there was no previous
222// last user index, use -1.
223func (q *queues) getNextQueueForQuerier(lastUserIndex int, querierID string) (userRequestQueue, string, int) {
224 uid := lastUserIndex
225
226 q.queuesMx.RLock()
227 defer q.queuesMx.RUnlock()
228
229 for iters := 0; iters < len(q.users); iters++ {
230 uid = uid + 1
231
232 // Don't use "mod len(q.users)", as that could skip users at the beginning of the list
233 // for example when q.users has shrunk since last call.
234 if uid >= len(q.users) {
235 uid = 0
236 }
237
238 u := q.users[uid]
239 if u == "" {
240 continue
241 }
242
243 uq := q.userQueues[u]
244
245 if uq.queriers != nil {
246 if _, ok := uq.queriers[querierID]; !ok {
247 // This querier is not handling the user.
248 continue
249 }
250 }
251
252 return uq.queue, u, uid
253 }
254 return nil, "", uid
255}
256
257func (q *queues) addQuerierConnection(querierID string) {
258 info := q.queriers[querierID]

Callers 6

TestQueuesFunction · 0.80
TestQueuesWithQueriersFunction · 0.80
TestQueuesConsistencyFunction · 0.80
TestQueueConcurrencyFunction · 0.80
confirmOrderForQuerierFunction · 0.80

Calls

no outgoing calls

Tested by 5

TestQueuesFunction · 0.64
TestQueuesWithQueriersFunction · 0.64
TestQueuesConsistencyFunction · 0.64
TestQueueConcurrencyFunction · 0.64
confirmOrderForQuerierFunction · 0.64