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() {
|
func (s *Service) RegisterHealthChecks() {
|
||||||
go func() { // startup register
|
go func() { // startup register
|
||||||
ticker := time.NewTicker(time.Second * 1)
|
ticker := time.NewTicker(time.Second)
|
||||||
for range ticker.C {
|
for range ticker.C {
|
||||||
if ok, _ := s.healthCheck(); ok {
|
if ok, _ := s.healthCheck(); ok {
|
||||||
ticker.Stop()
|
ticker.Stop()
|
||||||
@ -118,11 +118,11 @@ func (s *Service) RegisterHealthChecks() {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
go func() { // TTL
|
go func() { // TTL
|
||||||
interval := s.ttl - (time.Second * 2) // 2 seconds overhead
|
ticker := time.NewTicker(s.ttl)
|
||||||
ticker := time.NewTicker(interval)
|
|
||||||
for range ticker.C {
|
for range ticker.C {
|
||||||
if _, err := s.healthCheck(); err != nil {
|
if _, err := s.healthCheck(); err != nil {
|
||||||
fmt.Printf("HealthCheck endpoint not available (%s)#: %v\n", s.GetFullAddr(), err)
|
fmt.Printf("HealthCheck endpoint not available (%s)#: %v\n", s.GetFullAddr(), err)
|
||||||
|
ticker.Stop()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
Loading…
Reference in New Issue
Block a user