mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-03 16:59:22 +02:00
add options to adjust databroker lease ttl, and retry initial interval (#5391)
This commit is contained in:
parent
f876e2f31d
commit
ecd2855dcc
7 changed files with 79 additions and 13 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue