etcd3 API - v2.0.0
    Preparing search index...

    Class ComparatorBuilder

    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();
    }
    Index
    • Adds a new clause to the transaction.

      Parameters

      • key: string | Buffer<ArrayBufferLike>
      • column: "Lease" | "Version" | "Create" | "Mod" | "Value"
      • cmp: "==" | "===" | ">" | "<" | "!=" | "!=="
      • value: string | number | Buffer<ArrayBufferLike>

      Returns this

    • Sets the GRPC call options for this request.

      Parameters

      • options: CallOptions | undefined

      Returns this