mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-03-10 09:29:30 +00:00
Several packages are only used while running the e2e suite. These packages are less important to update, as the they can not influence the final executable that is part of the Ceph-CSI container-image. By moving these dependencies out of the main Ceph-CSI go.mod, it is easier to identify if a reported CVE affects Ceph-CSI, or only the testing (like most of the Kubernetes CVEs). Signed-off-by: Niels de Vos <ndevos@ibm.com>
36 lines
750 B
Go
36 lines
750 B
Go
package backoff
|
|
|
|
import "time"
|
|
|
|
type Timer interface {
|
|
Start(duration time.Duration)
|
|
Stop()
|
|
C() <-chan time.Time
|
|
}
|
|
|
|
// defaultTimer implements Timer interface using time.Timer
|
|
type defaultTimer struct {
|
|
timer *time.Timer
|
|
}
|
|
|
|
// C returns the timers channel which receives the current time when the timer fires.
|
|
func (t *defaultTimer) C() <-chan time.Time {
|
|
return t.timer.C
|
|
}
|
|
|
|
// Start starts the timer to fire after the given duration
|
|
func (t *defaultTimer) Start(duration time.Duration) {
|
|
if t.timer == nil {
|
|
t.timer = time.NewTimer(duration)
|
|
} else {
|
|
t.timer.Reset(duration)
|
|
}
|
|
}
|
|
|
|
// Stop is called when the timer is not used anymore and resources may be freed.
|
|
func (t *defaultTimer) Stop() {
|
|
if t.timer != nil {
|
|
t.timer.Stop()
|
|
}
|
|
}
|