|
| 1 | +--- |
| 2 | +id: mongo-instance |
| 3 | +title: 'MongoInstance' |
| 4 | +--- |
| 5 | + |
| 6 | +API Documentation of `MongoInstance`-Class |
| 7 | + |
| 8 | +## Functions |
| 9 | + |
| 10 | +### new |
| 11 | + |
| 12 | +Typings: `constructor(opts: Partial<MongodOpts>)` |
| 13 | + |
| 14 | +Create an new Instance without starting it |
| 15 | + |
| 16 | +:::tip |
| 17 | +When directly starting the instance, [`run`](#static-run) should be used |
| 18 | +::: |
| 19 | + |
| 20 | +### debug |
| 21 | + |
| 22 | +Typings: `private debug(msg: string): void` |
| 23 | + |
| 24 | +Format input with debug-message template |
| 25 | + |
| 26 | +### static-run |
| 27 | + |
| 28 | +Typings: `static async run(opts: Partial<MongodOpts>): Promise<MongoInstance>` |
| 29 | + |
| 30 | +Create an new Instance and start it (while being an Promise) |
| 31 | + |
| 32 | +### prepareCommandArgs |
| 33 | + |
| 34 | +Typings: `prepareCommandArgs(): string[]` |
| 35 | + |
| 36 | +Constructs the Command Arguments |
| 37 | + |
| 38 | +### run |
| 39 | + |
| 40 | +Typings: `async run(): Promise<this>` |
| 41 | + |
| 42 | +Start the `mongod` process |
| 43 | + |
| 44 | +### kill |
| 45 | + |
| 46 | +Typings: `async kill(): Promise<MongoInstance>` |
| 47 | + |
| 48 | +Stop the `mongod` process |
| 49 | + |
| 50 | +:::caution |
| 51 | +Will not Error if instance is not running |
| 52 | +::: |
| 53 | + |
| 54 | +### _launchMongod |
| 55 | + |
| 56 | +<span class="badge badge--warning">Internal</span> |
| 57 | + |
| 58 | +Typings: `_launchMongod(mongoBin: string): ChildProcess` |
| 59 | + |
| 60 | +Actually spawn the `mongod` process with `ChildProcess`, used by [`run`](#run) |
| 61 | + |
| 62 | +### _launchKiller |
| 63 | + |
| 64 | +<span class="badge badge--warning">Internal</span> |
| 65 | + |
| 66 | +Typings: `_launchKiller(parentPid: number, childPid: number): ChildProcess` |
| 67 | + |
| 68 | +Spawn an killer process that keeps watch over the `mongod` process |
| 69 | + |
| 70 | +### errorHandler |
| 71 | + |
| 72 | +<span class="badge badge--warning">Internal</span> |
| 73 | + |
| 74 | +Typings: `errorHandler(err: string): void` |
| 75 | + |
| 76 | +Error handler for the `mongod` process |
| 77 | + |
| 78 | +### closeHandler |
| 79 | + |
| 80 | +<span class="badge badge--warning">Internal</span> |
| 81 | + |
| 82 | +Typings: `closeHandler(code: number): void` |
| 83 | + |
| 84 | +Close handler for the `mongod` process |
| 85 | + |
| 86 | +### stderrHandler |
| 87 | + |
| 88 | +<span class="badge badge--warning">Internal</span> |
| 89 | + |
| 90 | +Typings: `stderrHandler(message: string | Buffer): void` |
| 91 | + |
| 92 | +STDERR handler for the `mongod` process |
| 93 | + |
| 94 | +### stdoutHandler |
| 95 | + |
| 96 | +<span class="badge badge--warning">Internal</span> |
| 97 | + |
| 98 | +Typings: `stdoutHandler(message: string | Buffer): void` |
| 99 | + |
| 100 | +STDOUT handler for the `mongod` process<br/> |
| 101 | +Matches process output against known formats and raise events |
| 102 | + |
| 103 | +## Values |
| 104 | + |
| 105 | +### instanceOpts |
| 106 | + |
| 107 | +Typings: `instanceOpts: MongoInstanceOpts` |
| 108 | + |
| 109 | +Stores the Instance Options |
| 110 | + |
| 111 | +### binaryOpts |
| 112 | + |
| 113 | +Typings: `readonly binaryOpts: Readonly<MongoBinaryOpts>` |
| 114 | + |
| 115 | +Stores the Binary Options |
| 116 | + |
| 117 | +### spawnOpts |
| 118 | + |
| 119 | +Typings: `readonly spawnOpts: Readonly<SpawnOptions>` |
| 120 | + |
| 121 | +Stores the Spawn Options |
| 122 | + |
| 123 | +### childProcess |
| 124 | + |
| 125 | +<span class="badge badge--warning">Internal</span> |
| 126 | + |
| 127 | +Typings: `childProcess?: ChildProcess` |
| 128 | + |
| 129 | +Stores the active process reference for the `mongod` process |
| 130 | + |
| 131 | +### killerProcess |
| 132 | + |
| 133 | +<span class="badge badge--warning">Internal</span> |
| 134 | + |
| 135 | +Typings: `killerProcess?: ChildProcess` |
| 136 | + |
| 137 | +Stores the active process reference for the killer process |
| 138 | + |
| 139 | +### isInstancePrimary |
| 140 | + |
| 141 | +Typings: `isInstancePrimary: boolean` |
| 142 | + |
| 143 | +Stores that the process is an Primary (ReplSet) |
| 144 | + |
| 145 | +### isInstanceReady |
| 146 | + |
| 147 | +Typings: `isInstanceReady: boolean` |
| 148 | + |
| 149 | +Stores that the process is fully started |
| 150 | + |
| 151 | +### isReplSet |
| 152 | + |
| 153 | +Typings: `isReplSet: boolean` |
| 154 | + |
| 155 | +Stores that the process is in an ReplSet |
0 commit comments