use timer instead of ticker

This commit is contained in:
Evgeniy Kulikov 2020-02-14 14:35:35 +03:00
parent 468cf49126
commit c4963f45bd
No known key found for this signature in database
GPG key ID: BF6AEE0A2A699BF2

View file

@ -78,7 +78,8 @@ func main() {
} }
func checkConnection(ctx context.Context, p *Pool) { func checkConnection(ctx context.Context, p *Pool) {
tick := time.NewTicker(time.Second * 15) dur := time.Second * 15
tick := time.NewTimer(dur)
loop: loop:
for { for {
@ -87,6 +88,7 @@ loop:
break loop break loop
case <-tick.C: case <-tick.C:
p.reBalance(ctx) p.reBalance(ctx)
tick.Reset(dur)
} }
} }