diff --git a/spec/ParseConfigKey.spec.js b/spec/ParseConfigKey.spec.js index a8f62681d9..c5f01456f8 100644 --- a/spec/ParseConfigKey.spec.js +++ b/spec/ParseConfigKey.spec.js @@ -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); diff --git a/src/Options/Definitions.js b/src/Options/Definitions.js index a1da6c09a7..6ccd397eb8 100644 --- a/src/Options/Definitions.js +++ b/src/Options/Definitions.js @@ -1051,6 +1051,12 @@ module.exports.DatabaseOptions = { action: parsers.booleanParser, default: false, }, + 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'), + }, maxPoolSize: { env: 'PARSE_SERVER_DATABASE_MAX_POOL_SIZE', help: @@ -1080,6 +1086,18 @@ 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'), }, + connectTimeoutMS: { + env: 'PARSE_SERVER_DATABASE_CONNECT_TIMEOUT_MS', + help: + 'Specifies 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'), + }, + socketTimeoutMS: { + env: 'PARSE_SERVER_DATABASE_SOCKET_TIMEOUT_MS', + help: + 'Specifies 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: { diff --git a/src/Options/docs.js b/src/Options/docs.js index 4c2883adaa..ad37f7c002 100644 --- a/src/Options/docs.js +++ b/src/Options/docs.js @@ -235,11 +235,14 @@ /** * @interface DatabaseOptions * @property {Boolean} enableSchemaHooks Enables database real-time hooks to update single schema cache. Set to `true` if using multiple Parse Servers instances connected to the same database. Failing to do so will cause a schema change to not propagate to all instances and re-syncing will only happen when the instances restart. To use this feature with MongoDB, a replica set cluster with [change stream](https://docs.mongodb.com/manual/changeStreams/#availability) support is required. + * @property {Number} minPoolSize The MongoDB driver option to set the minimum number of opened, cached, ready-to-use database connections maintained by the driver. * @property {Number} maxPoolSize The MongoDB driver option to set the maximum number of opened, cached, ready-to-use database connections maintained by the driver. * @property {Number} maxStalenessSeconds The MongoDB driver option to set the maximum replication lag for reads from secondary nodes. * @property {Number} maxTimeMS The MongoDB driver option to set a cumulative time limit in milliseconds for processing operations on a cursor. * @property {Boolean} retryWrites The MongoDB driver option to set whether to retry failed writes. * @property {Number} schemaCacheTtl 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. + * @property {Number} connectTimeoutMS Specifies 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. + * @property {Number} socketTimeoutMS Specifies the amount of time, in milliseconds, spent attempting to send or receive on a socket before timing out. Specifying 0 means no timeout. */ /** diff --git a/src/Options/index.js b/src/Options/index.js index 40e15afb27..3600f7d542 100644 --- a/src/Options/index.js +++ b/src/Options/index.js @@ -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; + /* Specifies 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 + /* Specifies the amount of time, in milliseconds, spent attempting to send or receive on a socket before timing out. Specifying 0 means no timeout. */ + socketTimeoutMS } export interface AuthAdapter {