From 1fb177fc716918f3892ff71e64c0f7206a3548d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20=C5=81uczak?= Date: Fri, 5 Jul 2024 17:13:50 +0200 Subject: [PATCH] fix: Check if we already have enough PreParams before first run --- pkg/generator/pool.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/generator/pool.go b/pkg/generator/pool.go index dc1b845b91..d9fe88bf89 100644 --- a/pkg/generator/pool.go +++ b/pkg/generator/pool.go @@ -76,7 +76,10 @@ func NewParameterPool[T any]( scheduler.compute(func(ctx context.Context) { start := time.Now() - generated := generateFn(ctx) + var generated *T = nil + if len(pool) < poolSize { + generated = generateFn(ctx) + } // The generateFn returns nil when the context is done. We should not // add nil element to the pool.