Release ticker resources

Signed-off-by: Matin Rahmanian <itsmatinx@gmail.com>
This commit is contained in:
Matin Rahmanian 2021-04-26 23:26:48 +02:00
parent a9d8a05d08
commit 835651e513
No known key found for this signature in database
GPG Key ID: 74443649F1F0D2D1

View File

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