|
|
@ -41,6 +41,8 @@ type Client struct { |
|
|
|
deregisterCriticalServiceAfter int |
|
|
|
deregisterCriticalServiceAfter int |
|
|
|
// serviceChecks user custom checks
|
|
|
|
// serviceChecks user custom checks
|
|
|
|
serviceChecks api.AgentServiceChecks |
|
|
|
serviceChecks api.AgentServiceChecks |
|
|
|
|
|
|
|
// reRegistry re-registry when service is deregistered
|
|
|
|
|
|
|
|
reRegistry bool |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func defaultResolver(_ context.Context, entries []*api.ServiceEntry) []*registry.ServiceInstance { |
|
|
|
func defaultResolver(_ context.Context, entries []*api.ServiceEntry) []*registry.ServiceInstance { |
|
|
@ -223,6 +225,7 @@ func (c *Client) Register(_ context.Context, svc *registry.ServiceInstance, enab |
|
|
|
err = c.cli.Agent().UpdateTTL("service:"+svc.ID, "pass", "pass") |
|
|
|
err = c.cli.Agent().UpdateTTL("service:"+svc.ID, "pass", "pass") |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
log.Errorf("[Consul] update ttl heartbeat to consul failed! err=%v", err) |
|
|
|
log.Errorf("[Consul] update ttl heartbeat to consul failed! err=%v", err) |
|
|
|
|
|
|
|
if c.reRegistry { |
|
|
|
// when the previous report fails, try to re register the service
|
|
|
|
// when the previous report fails, try to re register the service
|
|
|
|
time.Sleep(time.Duration(rand.Intn(5)) * time.Second) |
|
|
|
time.Sleep(time.Duration(rand.Intn(5)) * time.Second) |
|
|
|
if err := c.cli.Agent().ServiceRegister(asr); err != nil { |
|
|
|
if err := c.cli.Agent().ServiceRegister(asr); err != nil { |
|
|
@ -233,6 +236,7 @@ func (c *Client) Register(_ context.Context, svc *registry.ServiceInstance, enab |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
}() |
|
|
|
}() |
|
|
|
} |
|
|
|
} |
|
|
|
return nil |
|
|
|
return nil |
|
|
|