Merge pull request #1541 from ajnavarro/fix/call-cancel-if-any

This commit is contained in:
Antonio Navarro Perez 2021-03-24 11:35:41 +01:00 committed by GitHub
commit 7cf4233fdb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -66,6 +66,11 @@ func (l *leasedKV) Start(initValue string) error {
func (l *leasedKV) create(initValue string) (<-chan *clientv3.LeaseKeepAliveResponse, error) {
ctx, cancel := context.WithCancel(context.Background())
if l.cancel != nil {
l.cancel()
}
l.cancel = cancel
leaseResp, err := l.cli.Grant(ctx, l.ttlSeconds)