From e6d6ed1d4ec731ddcb3e2ff8a06225964971fb87 Mon Sep 17 00:00:00 2001 From: Alexander Garbett Date: Fri, 10 Nov 2023 13:54:23 +0000 Subject: [PATCH] Don't use Allow, because that consumes tokens --- mettle/worker/redis.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mettle/worker/redis.go b/mettle/worker/redis.go index bf19a55b..578c7d27 100644 --- a/mettle/worker/redis.go +++ b/mettle/worker/redis.go @@ -95,7 +95,7 @@ func (r *redisClient) ReadBlob(dg *pb.Digest) ([]byte, error) { ctx, cancel := context.WithTimeout(context.Background(), r.timeout) defer cancel() - if r.limiter.Allow() { + if r.limiter.Tokens() < 1.0 { cmd := r.readRedis.Get(ctx, dg.Hash) if err := cmd.Err(); err == nil { blob, _ := cmd.Bytes() @@ -226,7 +226,7 @@ func (r *redisClient) readBlobs(keys []string, metrics bool) [][]byte { if len(keys) == 0 { return nil } - if !r.limiter.Allow() { + if r.limiter.Tokens() < 1.0 { // Bail out immediately if Redis has exceeded error limit return nil }