Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace is the class on which CRUD operations can be invoked. The default namespace is the empty string, "". You can create nested namespaces by calling the namespace(prefix) method.

For example, if the current namespace is the default "" and you call namespace('user1/'), all operations on that new namespace will be automatically prefixed with user1/:

const client = new Etcd3();
const ns = client.namespace('user1/');

await ns.put('foo').value('bar'); // sets the key `user1/foo` to `bar`
await ns.delete().all(); // deletes all keys with the prefix `user1/`

Namespacing is particularly useful to avoid clashing between multiple applications and when using Etcd's access control.

Hierarchy

Index

Constructors

Protected constructor

Methods

delete

election

  • election(name: string, ttl?: undefined | number): Election
  • Creates a new Election instead. See more information on the Election class documentation.

    Parameters

    • name: string

      Name of the election in the etcd instance.

    • Optional ttl: undefined | number

      Lease TTL used in the election. This is the maximum time that a node which goes down can remain the leader before being automatically evicted.

    Returns Election

get

getAll

if

  • if() starts a new etcd transaction, which allows you to execute complex statements atomically. See documentation on the ComparatorBuilder for more information.

    Parameters

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

    Returns ComparatorBuilder

lease

  • lease() grants and returns a new Lease instance. The Lease is automatically kept alive for you until it is revoked. See the documentation on the Lease class for some examples.

    Parameters

    Returns Lease

lock

  • lock(key: string | Buffer): Lock
  • lock() is a helper to provide distributed locking capability. See the documentation on the Lock class for more information and examples.

    Parameters

    • key: string | Buffer

    Returns Lock

namespace

  • namespace(prefix: string | Buffer): Namespace
  • namespace adds a prefix and returns a new Namespace, which is used for operating on keys in a prefixed domain. For example, if the current namespace is the default "" and you call namespace('user1/'), all operations on that new namespace will be automatically prefixed with user1/. See the Namespace class for more details.

    Parameters

    • prefix: string | Buffer

    Returns Namespace

put

range

  • Creates a structure representing an etcd range. Used in permission grants and queries. This is a convenience method for Etcd3.Range.from(...).

    Parameters

    Returns Range

stm

  • stm() creates a new software transaction, see more details about how this works and why you might find this useful on the SoftwareTransaction class.

    Parameters

    Returns SoftwareTransaction

watch

Legend

  • Constructor
  • Method
  • Inherited method

Generated using TypeDoc