Merge pull request #3404 from itsmatinx/main

Release ticker resources
This commit is contained in:
Wang Yan 2021-05-05 16:40:13 +08:00 committed by GitHub
commit d0deff9cd6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -135,6 +135,7 @@ func PeriodicChecker(check Checker, period time.Duration) Checker {
u := NewStatusUpdater()
go func() {
t := time.NewTicker(period)
defer t.Stop()
for {
<-t.C
u.Update(check.Check())
@ -150,6 +151,7 @@ func PeriodicThresholdChecker(check Checker, period time.Duration, threshold int
tu := NewThresholdStatusUpdater(threshold)
go func() {
t := time.NewTicker(period)
defer t.Stop()
for {
<-t.C
tu.Update(check.Check())