MCPcopy
hub / github.com/grafana/tempo / getNextQueueForQuerier

Method getNextQueueForQuerier

modules/frontend/queue/user_queues.go:104–130  ·  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)

Source from the content-addressed store, hash-verified

102// to pass last user index returned by this function as argument. Is there was no previous
103// last user index, use -1.
104func (q *queues) getNextQueueForQuerier(lastUserIndex int) (chan Request, string, int) {
105 uid := lastUserIndex
106
107 for iters := 0; iters < len(q.users); iters++ {
108 uid = uid + 1
109
110 // Don't use "mod len(q.users)", as that could skip users at the beginning of the list
111 // for example when q.users has shrunk since last call.
112 if uid >= len(q.users) {
113 uid = 0
114 }
115
116 u := q.users[uid]
117 if u == "" {
118 continue
119 }
120
121 q := q.userQueues[u]
122
123 if len(q.ch) == 0 {
124 continue
125 }
126
127 return q.ch, u, uid
128 }
129 return nil, "", uid
130}

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected