From d3e61edf719821f76e47532b4a110320d3e3c1c6 Mon Sep 17 00:00:00 2001 From: Kevin Su Date: Mon, 25 Sep 2023 15:58:03 -0700 Subject: [PATCH] nit Signed-off-by: Kevin Su --- cache/auto_refresh.go | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/cache/auto_refresh.go b/cache/auto_refresh.go index c8b38f6..ef3ffb3 100644 --- a/cache/auto_refresh.go +++ b/cache/auto_refresh.go @@ -234,9 +234,10 @@ func (w *autoRefresh) enqueueBatches(ctx context.Context) error { } for _, batch := range batches { - b := batch - logger.Debugf(ctx, "Enqueuing batch with id: %v", b[0].GetID()) - w.workqueue.Add(b[0].GetID()) + for _, b := range batch { + logger.Debugf(ctx, "Enqueuing batch with id: %v", b.GetID()) + w.workqueue.Add(b.GetID()) + } } return nil @@ -274,26 +275,26 @@ func (w *autoRefresh) sync(ctx context.Context) (err error) { case <-ctx.Done(): return nil default: - itemId, shutdown := w.workqueue.Get() + itemID, shutdown := w.workqueue.Get() if shutdown { return nil } t := w.metrics.SyncLatency.Start() - item, ok := w.lruMap.Get(itemId) + item, ok := w.lruMap.Get(itemID) if !ok { - logger.Debugf(ctx, "item with id [%v] not found in cache", itemId) + logger.Debugf(ctx, "item with id [%v] not found in cache", itemID) return nil } updatedBatch, err := w.syncCb(ctx, Batch{itemWrapper{ - id: itemId.(ItemID), + id: itemID.(ItemID), item: item.(Item), }}) // Since we create batches every time we sync, we will just remove the item from the queue here // regardless of whether it succeeded the sync or not. - w.workqueue.Forget(item) - w.workqueue.Done(item) + w.workqueue.Forget(itemID) + w.workqueue.Done(itemID) if err != nil { w.metrics.SyncErrors.Inc()