From 6c819bcd91284f6a8140d50aac68c5a063595cff Mon Sep 17 00:00:00 2001 From: James Pickett Date: Fri, 13 Dec 2024 12:25:00 -0800 Subject: [PATCH] comments --- pkg/backoff/counter.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/backoff/counter.go b/pkg/backoff/counter.go index 497205654..6cb4915ca 100644 --- a/pkg/backoff/counter.go +++ b/pkg/backoff/counter.go @@ -10,6 +10,8 @@ type durationCounter struct { calcNext func(count int, baseDuration time.Duration) time.Duration } +// Next increments the count and returns the base interval multiplied by the count. +// If the result is greater than the maxDuration, maxDuration is returned. func (dc *durationCounter) Next() time.Duration { dc.count++ interval := dc.calcNext(dc.count, dc.baseInterval) @@ -19,10 +21,14 @@ func (dc *durationCounter) Next() time.Duration { return interval } +// Reset resets the count to 0. func (dc *durationCounter) Reset() { dc.count = 0 } +// NewMultiplicativeDurationCounter creates a new durationCounter that multiplies the base interval by the count. +// Count is incremented each time Next() is called and returns the base interval multiplied by the count. +// If the result is greater than the maxDuration, maxDuration is returned. func NewMultiplicativeDurationCounter(baseDuration, maxDuration time.Duration) *durationCounter { return &durationCounter{ baseInterval: baseDuration,