Closed willgm closed 6 years ago
Thanks for the request, this will be fixed in v0.2.10
@connor4312
is this fixed now? I'm having a similar problem.
const builder = ttl ? this.client.lease(ttl) : this.client;
return this.client
.if(key, 'Create', '==', 0)
.then(builder.put(key).value(value))
.else(this.client.get(key))
.commit();
So this code creates the lease. But unless I restart my app (or reload), the key won't be deleted. I mean, with TTlL=2 it just keeps the key alive and I can read it using etcdctl even after several seconds. However, as soon as I quit the app or reload the "browser" window (this is an electron app), the key gets removed.
Am I doing something wrong? I can use a setTimeout to explicitly revoke() the lease after X seconds, but this should be automatic, right?.
You should call builder.if
rather than this.client.if
to start the chain
@gtamas i got the same issue to fix create lease like this
const lease = client.lease(2, {
autoKeepAlive: false
});
by default lease is kept alive using setInterval internally https://github.com/microsoft/etcd3/blob/4b92eed/src/lease.ts#L73
If I put lease ttl to 1 sec and autoKeepAlive :false
and sleep my test for 3 sec only then the lease expires it should expires in 1 sec or is it expected behaviour?
When I use the
client.lease(ttl)
api, it automatically keeps it alive before the TTL ends using ansetTimeout
. But what if I do want the leasing to end and automatically revoke all the keys attached to it? I can't find an options to make it happens.