From 2ae65d28bda202b0af9ae518a46c3917a576a6e1 Mon Sep 17 00:00:00 2001 From: Vladimir Bauer Date: Tue, 20 Aug 2024 17:11:36 +0500 Subject: [PATCH] avoid negative time normalized values --- decor/eta.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/decor/eta.go b/decor/eta.go index 64ec74ae..bf48d3ee 100644 --- a/decor/eta.go +++ b/decor/eta.go @@ -164,7 +164,10 @@ func MaxTolerateTimeNormalizer(maxTolerate time.Duration) TimeNormalizer { } normalized -= time.Since(lastCall) lastCall = time.Now() - return normalized + if normalized > 0 { + return normalized + } + return remaining }) } @@ -183,7 +186,10 @@ func FixedIntervalTimeNormalizer(updInterval int) TimeNormalizer { count-- normalized -= time.Since(lastCall) lastCall = time.Now() - return normalized + if normalized > 0 { + return normalized + } + return remaining }) }