Options
All
  • Public
  • Public/Protected
  • All
Menu

MongoDB Instance Handler Class This Class starts & stops the "mongod" process directly and handles stdout, sterr and close events

Hierarchy

  • EventEmitter
    • MongoInstance

Implements

  • ManagerBase

Index

Constructors

constructor

Properties

Readonly binaryOpts

binaryOpts: Readonly<MongoBinaryOpts>

Optional extraConnectionOptions

extraConnectionOptions: MongoClientOptions

Extra options to append to "mongoclient.connect" Mainly used for authentication

instanceOpts

instanceOpts: MongoMemoryInstanceOpts

isInstancePrimary

isInstancePrimary: boolean = false

This boolean is "true" if the instance is elected to be PRIMARY

isInstanceReady

isInstanceReady: boolean = false

This boolean is "true" if the instance is successfully started

isReplSet

isReplSet: boolean = false

This boolean is "true" if the instance is part of an replset

Optional killerProcess

killerProcess: ChildProcess

The "mongo_killer" Process reference

Optional mongodProcess

mongodProcess: ChildProcess

The "mongod" Process reference

Readonly spawnOpts

spawnOpts: Readonly<SpawnOptions>

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.

Methods

_launchKiller

  • _launchKiller(parentPid: number, childPid: number): ChildProcess
  • Spawn an seperate process to kill the parent and the mongod instance to ensure "mongod" gets stopped in any case

    fires

    MongoInstance#killerLaunched

    Parameters

    • parentPid: number

      Parent nodejs process

    • childPid: number

      Mongod process to kill

    Returns ChildProcess

_launchMongod

  • _launchMongod(mongoBin: string): ChildProcess

addListener

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

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

          • Rest ...args: any[]

          Returns void

    Returns MongoInstance

Protected checkErrorInLine

  • checkErrorInLine(line: string): void

closeHandler

  • closeHandler(code: null | number, signal: null | string): void

Protected debug

  • debug(msg: string, ...extra: unknown[]): void

emit

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

errorHandler

  • errorHandler(err: string): void

eventNames

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

getMaxListeners

  • getMaxListeners(): number
  • Returns number

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

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

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

          • Rest ...args: any[]

          Returns void

    Returns MongoInstance

on

  • on(event: MongoInstanceEvents, listener: (...args: any[]) => void): MongoInstance

once

  • once(event: MongoInstanceEvents, listener: (...args: any[]) => void): MongoInstance

prepareCommandArgs

  • prepareCommandArgs(): string[]

prependListener

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

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

          • Rest ...args: any[]

          Returns void

    Returns MongoInstance

prependOnceListener

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

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

          • Rest ...args: any[]

          Returns void

    Returns MongoInstance

rawListeners

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

    • event: string | symbol

    Returns Function[]

removeAllListeners

  • Parameters

    • Optional event: string | symbol

    Returns MongoInstance

removeListener

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

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

          • Rest ...args: any[]

          Returns void

    Returns MongoInstance

setMaxListeners

  • Parameters

    • n: number

    Returns MongoInstance

start

  • start(): Promise<void>

stderrHandler

  • stderrHandler(message: string | Buffer): void

stdoutHandler

  • stdoutHandler(message: string | Buffer): void
  • Write STDOUT to debug function and process some special messages

    fires

    MongoInstance#instanceSTDOUT

    fires

    MongoInstance#instanceReady

    fires

    MongoInstance#instanceError

    fires

    MongoInstance#instancePrimary

    fires

    MongoInstance#instanceReplState

    Parameters

    • message: string | Buffer

      The STDOUT line to write/parse

    Returns void

stop

  • stop(): Promise<boolean>

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