@@ -16,11 +16,85 @@ const log = debug('MongoMS:MongoInstance');
1616
1717export type StorageEngine = 'devnull' | 'ephemeralForTest' | 'mmapv1' | 'wiredTiger' ;
1818
19+ /**
20+ * Overwrite replica member-specific configuration
21+ *
22+ * @see {@link https://docs.mongodb.com/manual/reference/replica-configuration/#replica-set-configuration-document-example }
23+ *
24+ * @example
25+ * ```ts
26+ * {
27+ * priority: 2,
28+ * buildIndexes: false,
29+ * votes: 2,
30+ * }
31+ * ```
32+ */
33+ export interface ReplicaMemberConfig {
34+ /**
35+ * A boolean that identifies an arbiter.
36+ * @defaultValue `false` - A value of `true` indicates that the member is an arbiter.
37+ */
38+ arbiterOnly ?: boolean ;
39+
40+ /**
41+ * A boolean that indicates whether the mongod builds indexes on this member.
42+ * You can only set this value when adding a member to a replica set.
43+ * @defaultValue `true`
44+ */
45+ buildIndexes ?: boolean ;
46+
47+ /**
48+ * The replica set hides this instance and does not include the member in the output of `db.hello()` or `hello`.
49+ * @defaultValue `true`
50+ */
51+ hidden ?: boolean ;
52+
53+ /**
54+ * A number that indicates the relative eligibility of a member to become a primary.
55+ * Specify higher values to make a member more eligible to become primary, and lower values to make the member less eligible.
56+ * @defaultValue 1.0 for primary/secondary; 0 for arbiters.
57+ */
58+ priority ?: number ;
59+
60+ /**
61+ * A tags document contains user-defined tag field and value pairs for the replica set member.
62+ * @defaultValue `null`
63+ * @example
64+ * ```ts
65+ * { "<tag1>": "<string1>", "<tag2>": "<string2>",... }
66+ * ```
67+ */
68+ tags ?: any ;
69+
70+ /**
71+ * Mongodb 4.x only - The number of seconds "behind" the primary that this replica set member should "lag".
72+ * For mongodb 5.x, use `secondaryDelaySecs` instead.
73+ * @see {@link https://docs.mongodb.com/v4.4/tutorial/configure-a-delayed-replica-set-member/ }
74+ * @defaultValue 0
75+ */
76+ slaveDelay ?: number ;
77+
78+ /**
79+ * Mongodb 5.x only - The number of seconds "behind" the primary that this replica set member should "lag".
80+ * @defaultValue 0
81+ */
82+ secondaryDelaySecs ?: number ;
83+
84+ /**
85+ * The number of votes a server will cast in a replica set election.
86+ * The number of votes each member has is either 1 or 0, and arbiters always have exactly 1 vote.
87+ * @defaultValue 1
88+ */
89+ votes ?: number ;
90+ }
91+
1992export interface MongoMemoryInstanceOptsBase {
2093 args ?: string [ ] ;
2194 port ?: number ;
2295 dbPath ?: string ;
2396 storageEngine ?: StorageEngine ;
97+ replicaMemberConfig ?: ReplicaMemberConfig ;
2498}
2599
26100export interface MongoMemoryInstanceOpts extends MongoMemoryInstanceOptsBase {
0 commit comments