Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add support for MongoDB databaseOptions keys minPoolSize, connectTimeoutMS, socketTimeoutMS #9522

Merged
merged 6 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions spec/ParseConfigKey.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ describe('Config Keys', () => {
maxTimeMS: 1000,
maxStalenessSeconds: 10,
maxPoolSize: 10,
minPoolSize: 5,
connectTimeoutMS: 5000,
socketTimeoutMS: 5000,
},
})).toBeResolved();
expect(loggerErrorSpy.calls.all().reduce((s, call) => s += call.args[0], '')).not.toMatch(invalidKeyErrorMessage);
Expand Down
18 changes: 18 additions & 0 deletions src/Options/Definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,12 @@ module.exports.FileUploadOptions = {
},
};
module.exports.DatabaseOptions = {
connectTimeoutMS: {
env: 'PARSE_SERVER_DATABASE_CONNECT_TIMEOUT_MS',
help:
'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.',
action: parsers.numberParser('connectTimeoutMS'),
},
enableSchemaHooks: {
env: 'PARSE_SERVER_DATABASE_ENABLE_SCHEMA_HOOKS',
help:
Expand All @@ -1068,6 +1074,12 @@ module.exports.DatabaseOptions = {
'The MongoDB driver option to set a cumulative time limit in milliseconds for processing operations on a cursor.',
action: parsers.numberParser('maxTimeMS'),
},
minPoolSize: {
env: 'PARSE_SERVER_DATABASE_MIN_POOL_SIZE',
help:
'The MongoDB driver option to set the minimum number of opened, cached, ready-to-use database connections maintained by the driver.',
action: parsers.numberParser('minPoolSize'),
},
retryWrites: {
env: 'PARSE_SERVER_DATABASE_RETRY_WRITES',
help: 'The MongoDB driver option to set whether to retry failed writes.',
Expand All @@ -1079,6 +1091,12 @@ module.exports.DatabaseOptions = {
'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.',
action: parsers.numberParser('schemaCacheTtl'),
},
socketTimeoutMS: {
env: 'PARSE_SERVER_DATABASE_SOCKET_TIMEOUT_MS',
help:
'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.',
action: parsers.numberParser('socketTimeoutMS'),
},
};
module.exports.AuthAdapter = {
enabled: {
Expand Down
3 changes: 3 additions & 0 deletions src/Options/docs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/Options/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -602,8 +602,14 @@ export interface DatabaseOptions {
maxTimeMS: ?number;
/* The MongoDB driver option to set the maximum replication lag for reads from secondary nodes.*/
maxStalenessSeconds: ?number;
/* The MongoDB driver option to set the minimum number of opened, cached, ready-to-use database connections maintained by the driver. */
minPoolSize: ?number;
/* The MongoDB driver option to set the maximum number of opened, cached, ready-to-use database connections maintained by the driver. */
maxPoolSize: ?number;
/* 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. */
connectTimeoutMS: ?number;
/* 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. */
socketTimeoutMS: ?number;
}

export interface AuthAdapter {
Expand Down
Loading