add options to adjust databroker lease ttl, and retry initial interval (#5391)

This commit is contained in:
Joe Kralicky 2024-12-13 14:01:43 -05:00 committed by GitHub
parent f876e2f31d
commit ecd2855dcc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 79 additions and 13 deletions

View file

@ -9,8 +9,9 @@ import (
)
type config struct {
maxInterval time.Duration
watches []watch
maxInterval time.Duration
initialInterval time.Duration
watches []watch
backoff.BackOff
}
@ -42,10 +43,18 @@ func WithMaxInterval(d time.Duration) Option {
}
}
// WithInitialInterval sets the initial backoff interval.
func WithInitialInterval(d time.Duration) Option {
return func(cfg *config) {
cfg.initialInterval = d
}
}
func newConfig(opts ...Option) ([]watch, backoff.BackOff) {
cfg := new(config)
for _, opt := range []Option{
WithMaxInterval(time.Minute * 5),
WithInitialInterval(backoff.DefaultInitialInterval),
} {
opt(cfg)
}
@ -59,6 +68,7 @@ func newConfig(opts ...Option) ([]watch, backoff.BackOff) {
}
bo := backoff.NewExponentialBackOff()
bo.InitialInterval = cfg.initialInterval
bo.MaxInterval = cfg.maxInterval
bo.MaxElapsedTime = 0
bo.Multiplier = 2