2023-04-10 15:36:59 +00:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
2020-09-16 20:10:06 +00:00
|
|
|
package e2eutil
|
|
|
|
|
|
|
|
import "time"
|
|
|
|
|
|
|
|
// WaitConfig is an interval and wait time that can be passed to a waiter
|
|
|
|
// function, but with a default value that comes from the OrDefault method
|
|
|
|
// if the config is nil
|
|
|
|
type WaitConfig struct {
|
|
|
|
Interval time.Duration
|
|
|
|
Retries int64
|
|
|
|
}
|
|
|
|
|
2021-08-30 09:08:12 +00:00
|
|
|
// OrDefault returns a default wait config of 10s.
|
2020-09-16 20:10:06 +00:00
|
|
|
func (wc *WaitConfig) OrDefault() (time.Duration, int64) {
|
|
|
|
if wc == nil {
|
|
|
|
return time.Millisecond * 100, 100
|
|
|
|
}
|
|
|
|
if wc.Interval == 0 {
|
|
|
|
wc.Interval = time.Millisecond * 100
|
|
|
|
}
|
|
|
|
if wc.Retries == 0 {
|
|
|
|
wc.Retries = 100
|
|
|
|
}
|
|
|
|
return wc.Interval, wc.Retries
|
|
|
|
}
|