INNER CODE UNIT · TypeScript

results

denodrivers/mongo · src/cluster.ts:99

    const results = await Promise.all(this.#protocols.map((protocol) => {
      return protocol.commandSingle(
        "admin",
        { isMaster: 1 },
      );
    }));
    const masterIndex = results.findIndex((result) =>
      result.isWritablePrimary || result.ismaster
    );
    if (masterIndex === -1) throw new Error(`Could not find a master node`);
    this.#masterIndex = masterIndex;
  }

  private getMaster() {
    return {
      protocol: this.#protocols[this.#masterIndex],
      conn: this.#connections[this.#masterIndex],
    };

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…