Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Commit

Permalink
nit
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin Su <[email protected]>
  • Loading branch information
pingsutw committed Sep 25, 2023
1 parent b09b997 commit d3e61ed
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions cache/auto_refresh.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Check warning on line 288 in cache/auto_refresh.go

View check run for this annotation

Codecov / codecov/patch

cache/auto_refresh.go#L286-L288

Added lines #L286 - L288 were not covered by tests
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()
Expand Down

0 comments on commit d3e61ed

Please sign in to comment.