修复自动续期一次的逻辑
This commit is contained in:
parent
9ff498706c
commit
33b3139dc5
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user