ReadonlynameThe name of the store (e.g. 'mongodb', 'redis', 'dynamodb')
ReadonlylibraryThe client library being used
Returns the underlying etcd3 client for anything not wrapped here.
Deletes a single key. Returns the number of keys actually deleted (0 or 1).
All key/value pairs whose key starts with prefix.
All keys (without values) starting with prefix.
Number of keys starting with prefix, without transferring their values.
Deletes every key starting with prefix. Returns the number of keys deleted.
Watch a single key for changes, invoking handler for every put/
delete on that key. Returns a handle whose cancel() stops the
underlying watch stream.
Watch every key starting with prefix for changes, invoking handler
for every put/delete on any matching key. Returns a handle whose
cancel() stops the underlying watch stream.
Grants a new lease with the given TTL (in seconds). By default the
lease is kept alive automatically in the background (autoKeepAlive);
pass { autoKeepAlive: false } to manage keep-alives manually via
keepAliveOnce(). Returns the lease ID, which can be passed to
put(key, value, { lease }) to associate keys with the lease so they
expire automatically when it does.
Puts key/value under a previously granted lease, so it expires when the lease does.
Fires a single, immediate keep-alive for a lease, resetting its TTL countdown.
Revokes a lease immediately, evicting every key still attached to it.
Stops sending keep-alives for a lease, letting it expire naturally when
its TTL elapses, instead of revoking it immediately. Use revokeLease()
to evict its keys right away.
Registers a handler that fires when etcd indicates a lease has been
lost (TTL expired without a successful keep-alive, or it was revoked
server-side). Not fired when revokeLease()/releaseLease() is called
locally and succeeds normally.
Acquires a distributed lock on key, blocking (queueing behind the
current holder, in acquisition order) until it's free rather than
rejecting immediately. Under the hood this is a lease on the key
that's revoked on release(), or timed out by etcd if the holder
dies - ttlSeconds controls that lease's TTL (etcd3 defaults to 30s).
Note: etcd3's own Lock#acquire() is a single compare-and-swap
attempt - it rejects immediately with EtcdLockFailedError if the
key already exists, rather than waiting, despite this store's docs
(and the in-repo test mock) describing blocking/queueing semantics.
To actually deliver that documented contract against a real etcd
server, acquireLockOrThrow() below retries: on
EtcdLockFailedError it watches the key until it's deleted (i.e. the
current holder released or its lease expired), then retries the CAS.
Multiple waiters can wake and race the retry simultaneously; that's
fine because the retry is itself a CAS - at most one of them wins
each round, and the rest go back to waiting.
OptionalttlSeconds: numberAcquires a distributed lock on key, runs fn, and releases the lock
once fn's result settles (whether it resolves or rejects). This is
the recommended way to use locks - it can't leak a held lock the way
manual acquireLock()/release() pairing can if fn throws.
Starts a raw etcd transaction: if (key.<column> <cmp> value) { ... }.
Returns etcd3's ComparatorBuilder directly so callers get its full
.and()/.then()/.else()/.commit() chain; combine with putOp()/
deleteOp()/getOp() below to build the then/else clauses.
const result = await store
.ifCompare('config-version', 'Value', '==', '1')
.then(store.putOp('config-version', '2'))
.else(store.getOp('config-version'))
.commit();
A put operation builder, for use as a .then()/.else() clause in ifCompare().
A delete operation builder, for use as a .then()/.else() clause in ifCompare().
A get operation builder, for use as a .then()/.else() clause in ifCompare().
Convenience compare-and-swap: atomically sets key to newValue only
if its current value equals expectedValue (or, if expectedValue is
null, only if the key does not currently exist). Returns whether the
swap happened.
Atomically deletes key only if its current value equals
expectedValue. Returns whether the delete happened.
EtcdStorewraps anetcd3client and exposes etcd's real primitives: key/value get/put/delete (single-key and prefix-range), watch, leases, distributed locking, and compare-and-swap transactions.