etcd3 API - v2.0.0
    Preparing search index...

    Class Campaign

    A Campaign is returned from Election.campaign. See the docs on that method for an example.

    Hierarchy

    • EventEmitter
      • Campaign
    Index
    • Parameters

      • namespace: Namespace
      • value: string | Buffer<ArrayBufferLike>
      • ttl: number

      Returns Campaign

    • Gets the etcd key in which the proclaimed value is stored. This is derived from the underlying lease, and thus may throw if the lease was not granted successfully.

      Returns Promise<string>

    • elected is fired when the current instance becomes the leader.

      Parameters

      • event: "elected"
      • handler: () => void

      Returns this

    • error is fired if the underlying lease experiences an error. When this is emitted, the campaign has failed. You should handle this and create a new campaign if appropriate.

      Parameters

      • event: "error"
      • handler: (error: Error) => void

      Returns this

    • Updates the value announced by this candidate (without starting a new election). If this candidate is currently the leader, then the change will be seen on other consumers as well.

      Parameters

      • value: string | Buffer<ArrayBufferLike>

      Returns Promise<void>

      NotCampaigningError if the instance is no longer campaigning

    • Resigns from the campaign. A new leader is elected if this instance was formerly the leader.

      Returns Promise<void>

    • Helper function that returns a promise when the node becomes the leader. If resign() is called before this happens, the promise never resolves. If an error is emitted, the promise is rejected.

      Returns Promise<Campaign>