fix in consul discovery lib
This commit is contained in:
parent
42532b1d44
commit
615281ae9a
@ -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()
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
Loading…
Reference in New Issue
Block a user