id is the watcher's ID in etcd. This is null
initially and during
reconnections, only populated while the watcher is idle.
Cancels the watcher.
lastRevision returns the latest etcd cluster revision that this
watcher observed. This will be null
if the watcher has not yet
connected.
connecting is fired when we send a request to etcd to queue this watcher.
connected is fired after etcd knowledges the watcher is connected.
When this event is fired, id
will already be populated.
data is fired when etcd reports an update on one of the keys being watched.
put is fired, in addition to data
, when a key is created
or updated in etcd.
delete is fired, in addition to data
, when a key is deleted from etcd.
end is fired after the watcher is closed normally. Like Node.js streams,
end is NOT fired if error
is fired.
disconnected is fired if the watcher is disconnected from etcd. The
watcher will automatically attempt to reconnect when this occurs. When
this event is fired, id
will still be populated if it was previously.
error is fired if a non-recoverable error occurs that prevents the watcher
from functioning. This generally occurs if etcd unexpectedly canceled our
lease, which can occur if (for example) we don't have permission to read
the watched key or range. When this event is fired, id
will still be
populated if it was previously.
Generated using TypeDoc
The Watcher is an event emitter that handles watching on a key or set of keys. See WatchBuilder for a usage example.