Skip to content

Commit 1b661e9

Browse files
authored
feat: Add support for MongoDB driver options serverSelectionTimeoutMS, maxIdleTimeMS, heartbeatFrequencyMS (#9910)
1 parent d5e7d6e commit 1b661e9

File tree

5 files changed

+33
-0
lines changed

5 files changed

+33
-0
lines changed

spec/ParseConfigKey.spec.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ describe('Config Keys', () => {
7878
maxStalenessSeconds: 10,
7979
maxPoolSize: 10,
8080
minPoolSize: 5,
81+
serverSelectionTimeoutMS: 5000,
82+
maxIdleTimeMS: 60000,
83+
heartbeatFrequencyMS: 10000,
8184
connectTimeoutMS: 5000,
8285
socketTimeoutMS: 5000,
8386
autoSelectFamily: true,

src/Options/Definitions.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,6 +1164,18 @@ module.exports.DatabaseOptions = {
11641164
action: parsers.booleanParser,
11651165
default: false,
11661166
},
1167+
heartbeatFrequencyMS: {
1168+
env: 'PARSE_SERVER_DATABASE_HEARTBEAT_FREQUENCY_MS',
1169+
help:
1170+
'The MongoDB driver option to specify the frequency in milliseconds at which the driver checks the state of the MongoDB deployment.',
1171+
action: parsers.numberParser('heartbeatFrequencyMS'),
1172+
},
1173+
maxIdleTimeMS: {
1174+
env: 'PARSE_SERVER_DATABASE_MAX_IDLE_TIME_MS',
1175+
help:
1176+
'The MongoDB driver option to specify the amount of time in milliseconds that a connection can remain idle in the connection pool before being removed and closed.',
1177+
action: parsers.numberParser('maxIdleTimeMS'),
1178+
},
11671179
maxPoolSize: {
11681180
env: 'PARSE_SERVER_DATABASE_MAX_POOL_SIZE',
11691181
help:
@@ -1199,6 +1211,12 @@ module.exports.DatabaseOptions = {
11991211
'The duration in seconds after which the schema cache expires and will be refetched from the database. Use this option if using multiple Parse Servers instances connected to the same database. A low duration will cause the schema cache to be updated too often, causing unnecessary database reads. A high duration will cause the schema to be updated too rarely, increasing the time required until schema changes propagate to all server instances. This feature can be used as an alternative or in conjunction with the option `enableSchemaHooks`. Default is infinite which means the schema cache never expires.',
12001212
action: parsers.numberParser('schemaCacheTtl'),
12011213
},
1214+
serverSelectionTimeoutMS: {
1215+
env: 'PARSE_SERVER_DATABASE_SERVER_SELECTION_TIMEOUT_MS',
1216+
help:
1217+
'The MongoDB driver option to specify the amount of time in milliseconds for a server to be considered suitable for selection.',
1218+
action: parsers.numberParser('serverSelectionTimeoutMS'),
1219+
},
12021220
socketTimeoutMS: {
12031221
env: 'PARSE_SERVER_DATABASE_SOCKET_TIMEOUT_MS',
12041222
help:

src/Options/docs.js

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Options/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,12 @@ export interface DatabaseOptions {
624624
minPoolSize: ?number;
625625
/* The MongoDB driver option to set the maximum number of opened, cached, ready-to-use database connections maintained by the driver. */
626626
maxPoolSize: ?number;
627+
/* The MongoDB driver option to specify the amount of time in milliseconds for a server to be considered suitable for selection. */
628+
serverSelectionTimeoutMS: ?number;
629+
/* The MongoDB driver option to specify the amount of time in milliseconds that a connection can remain idle in the connection pool before being removed and closed. */
630+
maxIdleTimeMS: ?number;
631+
/* The MongoDB driver option to specify the frequency in milliseconds at which the driver checks the state of the MongoDB deployment. */
632+
heartbeatFrequencyMS: ?number;
627633
/* The MongoDB driver option to specify the amount of time, in milliseconds, to wait to establish a single TCP socket connection to the server before raising an error. Specifying 0 disables the connection timeout. */
628634
connectTimeoutMS: ?number;
629635
/* The MongoDB driver option to specify the amount of time, in milliseconds, spent attempting to send or receive on a socket before timing out. Specifying 0 means no timeout. */

types/Options/index.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,9 @@ export interface DatabaseOptions {
234234
maxStalenessSeconds?: number;
235235
minPoolSize?: number;
236236
maxPoolSize?: number;
237+
serverSelectionTimeoutMS?: number;
238+
maxIdleTimeMS?: number;
239+
heartbeatFrequencyMS?: number;
237240
connectTimeoutMS?: number;
238241
socketTimeoutMS?: number;
239242
autoSelectFamily?: boolean;

0 commit comments

Comments
 (0)