Options
All
  • Public
  • Public/Protected
  • All
Menu

The Watcher is an event emitter that handles watching on a key or set of keys. See WatchBuilder for a usage example.

Hierarchy

  • EventEmitter
    • Watcher

Index

Properties

Methods

Properties

Readonly id

id: string | null = null

id is the watcher's ID in etcd. This is null initially and during reconnections, only populated while the watcher is idle.

Readonly request

Methods

cancel

  • cancel(): Promise<void>

lastRevision

  • lastRevision(): number | null
  • lastRevision returns the latest etcd cluster revision that this watcher observed. This will be null if the watcher has not yet connected.

    Returns number | null

on

  • on(event: "connecting", handler: (req: IWatchRequest) => void): this
  • on(event: "connected", handler: (res: IWatchResponse) => void): this
  • on(event: "data", handler: (res: IWatchResponse) => void): this
  • on(event: "put", handler: (kv: IKeyValue, previous?: RPC.IKeyValue) => void): this
  • on(event: "delete", handler: (kv: IKeyValue, previous?: RPC.IKeyValue) => void): this
  • on(event: "end", handler: () => void): this
  • on(event: "disconnected", handler: (res: EtcdError) => void): this
  • on(event: "error", handler: (err: EtcdError) => void): this
  • connecting is fired when we send a request to etcd to queue this watcher.

    Parameters

    Returns this

  • connected is fired after etcd knowledges the watcher is connected. When this event is fired, id will already be populated.

    Parameters

    Returns this

  • data is fired when etcd reports an update on one of the keys being watched.

    Parameters

    Returns this

  • put is fired, in addition to data, when a key is created or updated in etcd.

    Parameters

    • event: "put"
    • handler: (kv: IKeyValue, previous?: RPC.IKeyValue) => void
        • (kv: IKeyValue, previous?: RPC.IKeyValue): void
        • Parameters

          • kv: IKeyValue
          • Optional previous: RPC.IKeyValue

          Returns void

    Returns this

  • delete is fired, in addition to data, when a key is deleted from etcd.

    Parameters

    • event: "delete"
    • handler: (kv: IKeyValue, previous?: RPC.IKeyValue) => void
        • (kv: IKeyValue, previous?: RPC.IKeyValue): void
        • Parameters

          • kv: IKeyValue
          • Optional previous: RPC.IKeyValue

          Returns void

    Returns this

  • end is fired after the watcher is closed normally. Like Node.js streams, end is NOT fired if error is fired.

    Parameters

    • event: "end"
    • handler: () => void
        • (): void
        • Returns void

    Returns this

  • 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.

    Parameters

    Returns this

  • 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.

    Parameters

    Returns this

Legend

  • Constructor
  • Method
  • Inherited method

Generated using TypeDoc