Skip to content

Commit 91618fe

Browse files
authored
feat: Add support for MongoDB databaseOptions keys minPoolSize, connectTimeoutMS, socketTimeoutMS (#9522)
1 parent 3b20a6f commit 91618fe

File tree

4 files changed

+30
-0
lines changed

4 files changed

+30
-0
lines changed

Diff for: spec/ParseConfigKey.spec.js

+3
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ describe('Config Keys', () => {
8181
maxTimeMS: 1000,
8282
maxStalenessSeconds: 10,
8383
maxPoolSize: 10,
84+
minPoolSize: 5,
85+
connectTimeoutMS: 5000,
86+
socketTimeoutMS: 5000,
8487
},
8588
})).toBeResolved();
8689
expect(loggerErrorSpy.calls.all().reduce((s, call) => s += call.args[0], '')).not.toMatch(invalidKeyErrorMessage);

Diff for: src/Options/Definitions.js

+18
Original file line numberDiff line numberDiff line change
@@ -1043,6 +1043,12 @@ module.exports.FileUploadOptions = {
10431043
},
10441044
};
10451045
module.exports.DatabaseOptions = {
1046+
connectTimeoutMS: {
1047+
env: 'PARSE_SERVER_DATABASE_CONNECT_TIMEOUT_MS',
1048+
help:
1049+
'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.',
1050+
action: parsers.numberParser('connectTimeoutMS'),
1051+
},
10461052
enableSchemaHooks: {
10471053
env: 'PARSE_SERVER_DATABASE_ENABLE_SCHEMA_HOOKS',
10481054
help:
@@ -1068,6 +1074,12 @@ module.exports.DatabaseOptions = {
10681074
'The MongoDB driver option to set a cumulative time limit in milliseconds for processing operations on a cursor.',
10691075
action: parsers.numberParser('maxTimeMS'),
10701076
},
1077+
minPoolSize: {
1078+
env: 'PARSE_SERVER_DATABASE_MIN_POOL_SIZE',
1079+
help:
1080+
'The MongoDB driver option to set the minimum number of opened, cached, ready-to-use database connections maintained by the driver.',
1081+
action: parsers.numberParser('minPoolSize'),
1082+
},
10711083
retryWrites: {
10721084
env: 'PARSE_SERVER_DATABASE_RETRY_WRITES',
10731085
help: 'The MongoDB driver option to set whether to retry failed writes.',
@@ -1079,6 +1091,12 @@ module.exports.DatabaseOptions = {
10791091
'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.',
10801092
action: parsers.numberParser('schemaCacheTtl'),
10811093
},
1094+
socketTimeoutMS: {
1095+
env: 'PARSE_SERVER_DATABASE_SOCKET_TIMEOUT_MS',
1096+
help:
1097+
'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.',
1098+
action: parsers.numberParser('socketTimeoutMS'),
1099+
},
10821100
};
10831101
module.exports.AuthAdapter = {
10841102
enabled: {

Diff for: src/Options/docs.js

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: src/Options/index.js

+6
Original file line numberDiff line numberDiff line change
@@ -602,8 +602,14 @@ export interface DatabaseOptions {
602602
maxTimeMS: ?number;
603603
/* The MongoDB driver option to set the maximum replication lag for reads from secondary nodes.*/
604604
maxStalenessSeconds: ?number;
605+
/* The MongoDB driver option to set the minimum number of opened, cached, ready-to-use database connections maintained by the driver. */
606+
minPoolSize: ?number;
605607
/* The MongoDB driver option to set the maximum number of opened, cached, ready-to-use database connections maintained by the driver. */
606608
maxPoolSize: ?number;
609+
/* 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. */
610+
connectTimeoutMS: ?number;
611+
/* 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. */
612+
socketTimeoutMS: ?number;
607613
}
608614

609615
export interface AuthAdapter {

0 commit comments

Comments
 (0)