Adds a new clause to the transaction.
Runs the generated transaction and returns its result.
Adds one or more consequent clauses to be executed if the comparison is falsey.
Low-level method to add
Sets the GRPC call options for this request.
Adds one or more consequent clauses to be executed if the comparison is truthy.
Generated using TypeDoc
ComparatorBuilder builds a comparison between keys. This can be used for atomic operations in etcd, such as locking:
const id = uuid.v4(); function lock() { return client.if('my_lock', 'Create', '==', 0) .then(client.put('my_lock').value(id)) .else(client.get('my_lock')) .commit() .then(result => console.log(result.succeeded === id ? 'lock acquired' : 'already locked')); } function unlock() { return client.if('my_lock', 'Value', '==', id) .then(client.delete().key('my_lock')) .commit(); }