Compare commits

...

2 Commits

Author SHA1 Message Date
williamlardier 017b3befa7 ARSN-371: bump package version 2023-10-12 14:42:47 +02:00
williamlardier 4dd6ad7956 ARSN-371: support useUnifiedTopology as option 2023-10-12 14:42:37 +02:00
2 changed files with 6 additions and 2 deletions

View File

@ -91,7 +91,7 @@ class MongoClientInterface {
constructor(params) { constructor(params) {
const { replicaSetHosts, writeConcern, replicaSet, readPreference, path, const { replicaSetHosts, writeConcern, replicaSet, readPreference, path,
database, logger, replicationGroupId, authCredentials, database, logger, replicationGroupId, authCredentials,
isLocationTransient, shardCollections } = params; isLocationTransient, shardCollections, useUnifiedTopology } = params;
const cred = MongoUtils.credPrefix(authCredentials); const cred = MongoUtils.credPrefix(authCredentials);
this.mongoUrl = `mongodb://${cred}${replicaSetHosts}/` + this.mongoUrl = `mongodb://${cred}${replicaSetHosts}/` +
`?w=${writeConcern}&readPreference=${readPreference}`; `?w=${writeConcern}&readPreference=${readPreference}`;
@ -108,6 +108,7 @@ class MongoClientInterface {
this.database = database; this.database = database;
this.isLocationTransient = isLocationTransient; this.isLocationTransient = isLocationTransient;
this.shardCollections = shardCollections; this.shardCollections = shardCollections;
this.useUnifiedTopology = useUnifiedTopology;
this.concurrentCursors = (process.env.CONCURRENT_CURSORS && this.concurrentCursors = (process.env.CONCURRENT_CURSORS &&
!Number.isNaN(process.env.CONCURRENT_CURSORS)) !Number.isNaN(process.env.CONCURRENT_CURSORS))
@ -144,6 +145,9 @@ class MongoClientInterface {
socketTimeoutMS, socketTimeoutMS,
useNewUrlParser: true, useNewUrlParser: true,
}; };
if (this.useUnifiedTopology === true) {
options.useUnifiedTopology = true;
}
if (process.env.MONGO_POOL_SIZE && if (process.env.MONGO_POOL_SIZE &&
!Number.isNaN(process.env.MONGO_POOL_SIZE)) { !Number.isNaN(process.env.MONGO_POOL_SIZE)) {
options.poolSize = Number.parseInt(process.env.MONGO_POOL_SIZE, 10); options.poolSize = Number.parseInt(process.env.MONGO_POOL_SIZE, 10);

View File

@ -3,7 +3,7 @@
"engines": { "engines": {
"node": ">=16" "node": ">=16"
}, },
"version": "8.1.113", "version": "8.1.114",
"description": "Common utilities for the S3 project components", "description": "Common utilities for the S3 project components",
"main": "build/index.js", "main": "build/index.js",
"repository": { "repository": {