···263263}
264264265265// MaybeRemoveMissing will remove all queue items not in ids and return the
266266-// number of names removed from the queue. It will heuristically not run to
266266+// ids of items removed from the queue. It will heuristically not run to
267267// conserve resources.
268268//
269269// In the server's steady state we expect that the list of names is equal to
···271271// removals. Removal requires memory allocation and coarse locking. To avoid
272272// that we use a heuristic which can falsely decide it doesn't need to
273273// remove. However, we will converge onto removing items.
274274-func (q *Queue) MaybeRemoveMissing(ids []uint32) uint {
274274+func (q *Queue) MaybeRemoveMissing(ids []uint32) []uint32 {
275275 q.mu.Lock()
276276 sameSize := len(q.items) == len(ids)
277277 q.mu.Unlock()
···279279 // heuristically skip expensive work
280280 if sameSize {
281281 debug.Printf("skipping MaybeRemoveMissing due to same size: %d", len(ids))
282282- return 0
282282+ return nil
283283 }
284284285285 set := make(map[uint32]struct{}, len(ids))
···290290 q.mu.Lock()
291291 defer q.mu.Unlock()
292292293293- var count uint
293293+ var removed []uint32
294294 for _, item := range q.items {
295295 if _, ok := set[item.opts.RepoID]; ok {
296296 continue
···303303 item.indexState = ""
304304305305 delete(q.items, item.opts.RepoID)
306306- count++
306306+307307+ removed = append(removed, item.opts.RepoID)
307308 }
308309309310 metricQueueLen.Set(float64(len(q.pq)))
310311 metricQueueCap.Set(float64(len(q.items)))
311312312312- return count
313313+ return removed
313314}
314315315316// getOrAdd returns the item for repoID. If the repoID hasn't been seen before, it