1
0
mirror of https://github.com/go-micro/go-micro.git synced 2024-11-24 08:02:32 +02:00

Merge pull request #313 from lovelly/master

Fix tcp check no ttl error
This commit is contained in:
Asim Aslam 2018-11-03 12:16:56 +00:00 committed by GitHub
commit c8a35afc92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -180,10 +180,21 @@ func (c *consulRegistry) Register(s *Service, opts ...RegisterOption) error {
// if it's already registered and matches then just pass the check
if ok && v == h {
// if the err is nil we're all good, bail out
// if not, we don't know what the state is, so full re-register
if err := c.Client.Agent().PassTTL("service:"+node.Id, ""); err == nil {
return nil
if options.TTL == time.Duration(0) {
services,_, err := c.Client.Health().Checks(s.Name, nil)
if err == nil {
for _, v := range services {
if v.ServiceID == node.Id {
return nil
}
}
}
}else{
// if the err is nil we're all good, bail out
// if not, we don't know what the state is, so full re-register
if err := c.Client.Agent().PassTTL("service:"+node.Id, ""); err == nil {
return nil
}
}
}