Skip to content

Commit 20f2071

Browse files
authored
feat: Add support for MongoDB databaseOptions keys minPoolSize, connectTimeoutMS, socketTimeoutMS, autoSelectFamily, autoSelectFamilyAttemptTimeout (#9577)
1 parent 6114cd9 commit 20f2071

File tree

4 files changed

+50
-0
lines changed

4 files changed

+50
-0
lines changed

Diff for: spec/ParseConfigKey.spec.js

+5
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ describe('Config Keys', () => {
8181
maxTimeMS: 1000,
8282
maxStalenessSeconds: 10,
8383
maxPoolSize: 10,
84+
minPoolSize: 5,
85+
connectTimeoutMS: 5000,
86+
socketTimeoutMS: 5000,
87+
autoSelectFamily: true,
88+
autoSelectFamilyAttemptTimeout: 3000
8489
},
8590
})).toBeResolved();
8691
expect(loggerErrorSpy.calls.all().reduce((s, call) => s += call.args[0], '')).not.toMatch(invalidKeyErrorMessage);

Diff for: src/Options/Definitions.js

+30
Original file line numberDiff line numberDiff line change
@@ -1044,6 +1044,24 @@ module.exports.FileUploadOptions = {
10441044
},
10451045
};
10461046
module.exports.DatabaseOptions = {
1047+
autoSelectFamily: {
1048+
env: 'PARSE_SERVER_DATABASE_AUTO_SELECT_FAMILY',
1049+
help:
1050+
'The MongoDB driver option to set whether the socket attempts to connect to IPv6 and IPv4 addresses until a connection is established. If available, the driver will select the first IPv6 address.',
1051+
action: parsers.booleanParser,
1052+
},
1053+
autoSelectFamilyAttemptTimeout: {
1054+
env: 'PARSE_SERVER_DATABASE_AUTO_SELECT_FAMILY_ATTEMPT_TIMEOUT',
1055+
help:
1056+
'The MongoDB driver option to specify the amount of time in milliseconds to wait for a connection attempt to finish before trying the next address when using the autoSelectFamily option. If set to a positive integer less than 10, the value 10 is used instead.',
1057+
action: parsers.numberParser('autoSelectFamilyAttemptTimeout'),
1058+
},
1059+
connectTimeoutMS: {
1060+
env: 'PARSE_SERVER_DATABASE_CONNECT_TIMEOUT_MS',
1061+
help:
1062+
'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.',
1063+
action: parsers.numberParser('connectTimeoutMS'),
1064+
},
10471065
enableSchemaHooks: {
10481066
env: 'PARSE_SERVER_DATABASE_ENABLE_SCHEMA_HOOKS',
10491067
help:
@@ -1069,6 +1087,12 @@ module.exports.DatabaseOptions = {
10691087
'The MongoDB driver option to set a cumulative time limit in milliseconds for processing operations on a cursor.',
10701088
action: parsers.numberParser('maxTimeMS'),
10711089
},
1090+
minPoolSize: {
1091+
env: 'PARSE_SERVER_DATABASE_MIN_POOL_SIZE',
1092+
help:
1093+
'The MongoDB driver option to set the minimum number of opened, cached, ready-to-use database connections maintained by the driver.',
1094+
action: parsers.numberParser('minPoolSize'),
1095+
},
10721096
retryWrites: {
10731097
env: 'PARSE_SERVER_DATABASE_RETRY_WRITES',
10741098
help: 'The MongoDB driver option to set whether to retry failed writes.',
@@ -1080,6 +1104,12 @@ module.exports.DatabaseOptions = {
10801104
'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.',
10811105
action: parsers.numberParser('schemaCacheTtl'),
10821106
},
1107+
socketTimeoutMS: {
1108+
env: 'PARSE_SERVER_DATABASE_SOCKET_TIMEOUT_MS',
1109+
help:
1110+
'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.',
1111+
action: parsers.numberParser('socketTimeoutMS'),
1112+
},
10831113
};
10841114
module.exports.AuthAdapter = {
10851115
enabled: {

Diff for: src/Options/docs.js

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

Diff for: src/Options/index.js

+10
Original file line numberDiff line numberDiff line change
@@ -602,8 +602,18 @@ 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;
613+
/* The MongoDB driver option to set whether the socket attempts to connect to IPv6 and IPv4 addresses until a connection is established. If available, the driver will select the first IPv6 address. */
614+
autoSelectFamily: ?boolean;
615+
/* The MongoDB driver option to specify the amount of time in milliseconds to wait for a connection attempt to finish before trying the next address when using the autoSelectFamily option. If set to a positive integer less than 10, the value 10 is used instead. */
616+
autoSelectFamilyAttemptTimeout: ?number;
607617
}
608618

609619
export interface AuthAdapter {

0 commit comments

Comments
 (0)