diff --git a/consul/discovery.go b/consul/discovery.go index 2d74f5b..0548141 100644 --- a/consul/discovery.go +++ b/consul/discovery.go @@ -109,7 +109,7 @@ func (s *Service) Unregister() error { func (s *Service) RegisterHealthChecks() { go func() { // startup register - ticker := time.NewTicker(time.Second * 1) + ticker := time.NewTicker(time.Second) for range ticker.C { if ok, _ := s.healthCheck(); ok { ticker.Stop() @@ -118,11 +118,11 @@ func (s *Service) RegisterHealthChecks() { }() go func() { // TTL - interval := s.ttl - (time.Second * 2) // 2 seconds overhead - ticker := time.NewTicker(interval) + ticker := time.NewTicker(s.ttl) for range ticker.C { if _, err := s.healthCheck(); err != nil { fmt.Printf("HealthCheck endpoint not available (%s)#: %v\n", s.GetFullAddr(), err) + ticker.Stop() } } }()