lib/config: Allow sub-second watcher delay (fixes #7859) (#7864)

Allow the watcher delay to take fractional values, effectively allowing
for much shorter delays. The minimum value is limited at 0.01, which
effectively translates to 10ms. This is required in order to guarantee
that there is still enough time to aggregate multiple single change
events.

Signed-off-by: Tomasz Wilczyński <twilczynski@naver.com>
This commit is contained in:
tomasz1986
2023-03-18 08:50:38 +01:00
committed by GitHub
parent 59de7048bd
commit 358cf25cff
5 changed files with 174 additions and 178 deletions
+6 -4
View File
@@ -456,10 +456,12 @@ func updateInProgressSet(event events.Event, inProgress map[string]struct{}) {
// air, they were just considered as a sensible compromise between fast updates and
// saving resources. For short delays the timeout is 6 times the delay, capped at 1
// minute. For delays longer than 1 minute, the delay and timeout are equal.
func notifyTimeout(eventDelayS int) time.Duration {
shortDelayS := 10
shortDelayMultiplicator := 6
longDelayS := 60
func notifyTimeout(eventDelayS float64) time.Duration {
const (
shortDelayS = 10
shortDelayMultiplicator = 6
longDelayS = 60
)
longDelayTimeout := time.Duration(1) * time.Minute
if eventDelayS < shortDelayS {
return time.Duration(eventDelayS*shortDelayMultiplicator) * time.Second