Skip to content
Snippets Groups Projects
Commit a1e3824c authored by Joe Zou's avatar Joe Zou Committed by GitHub
Browse files

Merge pull request #738 from zhangshen023/etcd-lease

Fix: add etcdv3 lease to defeat provider register info left in the registry when provider app  panic
parents 73edb6b6 df23b9e6
No related branches found
No related tags found
No related merge requests found
......@@ -112,8 +112,9 @@ func (r *etcdV3Registry) InitListeners() {
}
// DoRegister actually do the register job in the registry center of etcd
// for lease
func (r *etcdV3Registry) DoRegister(root string, node string) error {
return r.client.Create(path.Join(root, node), "")
return r.client.RegisterTemp(path.Join(root, node), "")
}
// nolint
......
......@@ -408,7 +408,8 @@ func (c *Client) keepAliveKV(k string, v string) error {
return ErrNilETCDV3Client
}
lease, err := c.rawClient.Grant(c.ctx, int64(time.Second.Seconds()))
// make lease time longer, since 1 second is too short
lease, err := c.rawClient.Grant(c.ctx, int64(30*time.Second.Seconds()))
if err != nil {
return perrors.WithMessage(err, "grant lease")
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment