Options
All
  • Public
  • Public/Protected
  • All
Menu

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

Hierarchy

  • EventEmitter
    • Campaign

Index

Constructors

constructor

Methods

getCampaignKey

  • getCampaignKey(): Promise<string>
  • 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>

on

  • on(event: "elected", handler: () => void): this
  • on(event: "error", handler: (error: Error) => void): this
  • elected is fired when the current instance becomes the leader.

    Parameters

    • event: "elected"
    • handler: () => void
        • (): void
        • Returns 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
        • Parameters

          Returns void

    Returns this

proclaim

  • proclaim(value: string | Buffer): Promise<void>
  • 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.

    throws

    NotCampaigningError if the instance is no longer campaigning

    Parameters

    • value: string | Buffer

    Returns Promise<void>

resign

  • resign(): Promise<void>
  • Resigns from the campaign. A new leader is elected if this instance was formerly the leader.

    Returns Promise<void>

wait

  • wait(): Promise<this>
  • 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<this>

Legend

  • Constructor
  • Method
  • Inherited method

Generated using TypeDoc