Skip to content

Commit

Permalink
Set default for BackfillQueueSize if negative
Browse files Browse the repository at this point in the history
Signed-off-by: notfelineit <[email protected]>
  • Loading branch information
notfelineit committed Apr 12, 2024
1 parent f118ba2 commit 3105f46
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions go/vt/vtadmin/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ const (
// backfill requests to still process, if a config is passed with a
// non-positive BackfillRequestTTL.
DefaultBackfillRequestTTL = time.Millisecond * 100
// DefaultBackfillQueueSize is the default value used for the size of the
// backfill queue, if a config is passed with a non-positive BackfillQueueSize.
DefaultBackfillQueueSize = 1
)

// Config is the configuration for a cache.
Expand Down Expand Up @@ -125,6 +128,11 @@ func New[Key Keyer, Value any](fillFunc func(ctx context.Context, req Key) (Valu
cfg.BackfillRequestTTL = DefaultBackfillRequestTTL
}

if cfg.BackfillQueueSize <= 0 {
log.Warningf("BackfillQueueSize (%v) must be positive, defaulting to %v", cfg.BackfillQueueSize, DefaultBackfillQueueSize)
cfg.BackfillQueueSize = DefaultBackfillQueueSize
}

c := &Cache[Key, Value]{
cache: cache.New(cfg.DefaultExpiration, cfg.CleanupInterval),
lastFill: map[string]time.Time{},
Expand Down

0 comments on commit 3105f46

Please sign in to comment.