Options
All
  • Public
  • Public/Protected
  • All
Menu

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();
}

Hierarchy

  • ComparatorBuilder

Index

Constructors

constructor

Methods

and

  • and(key: string | Buffer, column: keyof typeof CompareTarget, cmp: keyof typeof comparator, value: string | Buffer | number): this
  • Adds a new clause to the transaction.

    Parameters

    • key: string | Buffer
    • column: keyof typeof CompareTarget
    • cmp: keyof typeof comparator
    • value: string | Buffer | number

    Returns this

commit

else

mapOperations

options

  • options(options: CallOptions | undefined): this
  • Sets the GRPC call options for this request.

    Parameters

    • options: CallOptions | undefined

    Returns this

then

Legend

  • Constructor
  • Method
  • Inherited method

Generated using TypeDoc