Skip to content

Commit

Permalink
fix: fix consul heartbeat 404 error
Browse files Browse the repository at this point in the history
this is will happen when heartbeat start after deregister
  • Loading branch information
lawlielt committed Jan 4, 2024
1 parent 85740b1 commit 6a19992
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion contrib/registry/consul/client.go
Expand Up @@ -220,7 +220,11 @@ func (c *Client) Register(_ context.Context, svc *registry.ServiceInstance, enab
_ = c.cli.Agent().ServiceDeregister(svc.ID)
return
}
err = c.cli.Agent().UpdateTTL("service:"+svc.ID, "pass", "pass")
err = c.cli.Agent().UpdateTTLOpts("service:"+svc.ID, "pass", "pass", new(api.QueryOptions).WithContext(c.ctx))
if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) {
_ = c.cli.Agent().ServiceDeregister(svc.ID)
return
}
if err != nil {
log.Errorf("[Consul] update ttl heartbeat to consul failed! err=%v", err)
// when the previous report fails, try to re register the service
Expand Down

0 comments on commit 6a19992

Please sign in to comment.