Options
All
  • Public
  • Public/Protected
  • All
Menu

Class for managing an replSet

Hierarchy

  • EventEmitter
    • MongoMemoryReplSet

Implements

  • ManagerAdvanced

Index

Constructors

constructor

Properties

Protected _binaryOpts

_binaryOpts: MongoBinaryOpts

Options for the Binary across all instances

Protected _instanceOpts

_instanceOpts: MongoMemoryInstanceOptsBase[]

Options for individual instances

Protected Optional _keyfiletmp

_keyfiletmp: string

TMPDIR for the keyfile, when auth is used

Protected _ranCreateAuth

_ranCreateAuth: boolean = false

Protected _replSetOpts

_replSetOpts: Required<ReplSetOpts>

Options for the Replset itself and defaults for instances

Protected _state

_state: MongoMemoryReplSetStates = ...

servers

servers: MongoMemoryServer[] = []

All servers this ReplSet instance manages

Static Readonly captureRejectionSymbol

captureRejectionSymbol: typeof captureRejectionSymbol

Static captureRejections

captureRejections: boolean

Sets or gets the default captureRejection value for all emitters.

Static defaultMaxListeners

defaultMaxListeners: number

Static Readonly errorMonitor

errorMonitor: typeof errorMonitor

This symbol shall be used to install a listener for only monitoring 'error' events. Listeners installed using this symbol are called before the regular 'error' listeners are called.

Installing a listener using this symbol does not change the behavior once an 'error' event is emitted, therefore the process will still crash if no regular 'error' listener is installed.

Accessors

binaryOpts

  • get binaryOpts(): MongoBinaryOpts
  • set binaryOpts(val: MongoBinaryOpts): void

instanceOpts

  • get instanceOpts(): MongoMemoryInstanceOptsBase[]
  • set instanceOpts(val: MongoMemoryInstanceOptsBase[]): void

replSetOpts

  • get replSetOpts(): ReplSetOpts
  • set replSetOpts(val: ReplSetOpts): void

state

  • get state(): MongoMemoryReplSetStates

Methods

Protected _initReplSet

  • _initReplSet(): Promise<void>
  • Connects to the first server from the list of servers and issues the replSetInitiate command passing in a new replica set configuration object.

    throws

    if state is not "init"

    throws

    if "servers.length" is not 1 or above

    throws

    if package "mongodb" is not installed

    Returns Promise<void>

Protected _initServer

Protected _waitForPrimary

  • _waitForPrimary(timeout?: number, where?: string): Promise<void>
  • Wait until the replSet has elected a Primary

    throws

    if timeout is reached

    Parameters

    • timeout: number = ...

      Timeout to not run infinitly, default: 30s

    • Optional where: string

      Extra Parameter for logging to know where this function was called

    Returns Promise<void>

addListener

  • addListener(event: string | symbol, listener: (...args: any[]) => void): MongoMemoryReplSet
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns MongoMemoryReplSet

cleanup

  • cleanup(force: boolean): Promise<void>
  • cleanup(options?: Cleanup): Promise<void>
  • Remove the defined dbPath's

    throws

    If "state" is not "stopped"

    throws

    If "instanceInfo" is not defined

    throws

    If an fs error occured

    deprecated

    replace argument with Cleanup interface object

    Parameters

    • force: boolean

      Remove the dbPath even if it is no "tmpDir" (and re-check if tmpDir actually removed it)

    Returns Promise<void>

  • Remove the defined dbPath's

    throws

    If "state" is not "stopped"

    throws

    If "instanceInfo" is not defined

    throws

    If an fs error occured

    Parameters

    • Optional options: Cleanup

      Set how to run a cleanup, by default { doCleanup: true } is used

    Returns Promise<void>

emit

  • emit(event: stateChange, ...args: any[]): boolean

Protected enableAuth

  • enableAuth(): boolean

Protected ensureKeyFile

  • ensureKeyFile(): Promise<string>

eventNames

  • eventNames(): (string | symbol)[]
  • Returns (string | symbol)[]

Protected getInstanceOpts

  • getInstanceOpts(baseOpts?: MongoMemoryInstanceOptsBase, keyfileLocation?: string): MongoMemoryInstanceOpts

getMaxListeners

  • getMaxListeners(): number
  • Returns number

getUri

  • getUri(otherDb?: string, otherIp?: string): string

Protected initAllServers

  • initAllServers(): Promise<void>

listenerCount

  • listenerCount(event: string | symbol): number
  • Parameters

    • event: string | symbol

    Returns number

listeners

  • listeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

off

  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns MongoMemoryReplSet

on

once

prependListener

  • prependListener(event: string | symbol, listener: (...args: any[]) => void): MongoMemoryReplSet
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns MongoMemoryReplSet

prependOnceListener

  • prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): MongoMemoryReplSet
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns MongoMemoryReplSet

rawListeners

  • rawListeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

removeAllListeners

  • Parameters

    • Optional event: string | symbol

    Returns MongoMemoryReplSet

removeListener

  • removeListener(event: string | symbol, listener: (...args: any[]) => void): MongoMemoryReplSet
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns MongoMemoryReplSet

setMaxListeners

  • Parameters

    • n: number

    Returns MongoMemoryReplSet

start

  • start(): Promise<void>

Protected stateChange

  • stateChange(newState: MongoMemoryReplSetStates, ...args: any[]): void

stop

  • stop(runCleanup: boolean): Promise<boolean>
  • stop(cleanupOptions?: Cleanup): Promise<boolean>

waitUntilRunning

  • waitUntilRunning(): Promise<void>

Static create

Static listenerCount

  • listenerCount(emitter: EventEmitter, event: string | symbol): number
  • deprecated

    since v4.0.0

    Parameters

    • emitter: EventEmitter
    • event: string | symbol

    Returns number

Static on

  • on(emitter: EventEmitter, event: string): AsyncIterableIterator<any>
  • Parameters

    • emitter: EventEmitter
    • event: string

    Returns AsyncIterableIterator<any>

Static once

  • once(emitter: NodeEventTarget, event: string | symbol): Promise<any[]>
  • once(emitter: DOMEventTarget, event: string): Promise<any[]>
  • Parameters

    • emitter: NodeEventTarget
    • event: string | symbol

    Returns Promise<any[]>

  • Parameters

    • emitter: DOMEventTarget
    • event: string

    Returns Promise<any[]>

Generated using TypeDoc