feature/etcd #6

Merged
zhangdeman merged 5 commits from feature/etcd into master 2021-11-24 14:25:10 +08:00
Showing only changes of commit 33b3139dc5 - Show all commits

View File

@ -42,10 +42,11 @@ func LeaseOnce(ctx context.Context, key string, val string, ttl int64) error {
} }
// ttl 秒钟之后, 这个key就会被移除 // ttl 秒钟之后, 这个key就会被移除
if _, err = Client.Put(context.TODO(), key, val, clientv3.WithLease(resp.ID)); err != nil { if _, err = Client.Put(ctx, key, val, clientv3.WithLease(resp.ID)); err != nil {
return errors.New("lease key put fail : " + err.Error()) return errors.New("lease key put fail : " + err.Error())
} }
return nil _, err = Client.KeepAliveOnce(ctx, resp.ID)
return err
} }
// LeaseKeepAliveForever 无限续租一个key // LeaseKeepAliveForever 无限续租一个key