Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Socket options
var socketOptions = options.socketOptions && Object.keys(options.socketOptions).length > 0
? options.socketOptions : options;
// Translate all the options to the mongodb-core ones
clonedOptions = translateOptions(clonedOptions, socketOptions);
if(typeof clonedOptions.keepAlive == 'number') {
clonedOptions.keepAliveInitialDelay = clonedOptions.keepAlive;
clonedOptions.keepAlive = clonedOptions.keepAlive > 0;
}
// console.log("=============== create CReplSet")
// console.dir(clonedOptions)
// Create the ReplSet
var replset = new CReplSet(seedlist, clonedOptions);
// Server capabilities
var sCapabilities = null;
// Listen to reconnect event
replset.on('reconnect', function() {
self.emit('reconnect');
store.execute();
});
// Internal state
this.s = {
// Replicaset
replset: replset
// Server capabilities
, sCapabilities: null
// Debug tag
GridStoreStream.prototype.write = function(chunk, encoding, callback) {
var self = this;
if(self.endCalled) return self.emit('error', MongoError.create({message: 'attempting to write to stream after end called', driver:true}))
// Do we have to open the gridstore
if(!self.gs.isOpen) {
self.gs.open(function() {
self.gs.isOpen = true;
self.gs.write(chunk, function() {
process.nextTick(function() {
self.emit('drain');
});
});
});
return false;
} else {
self.gs.write(chunk, function() {
self.emit('drain');
});
return true;
const index = arguments.length - 1;
const cb = arguments[index];
if (typeof cb === "function") {
arguments[index] = function() {
if (trace) trace.end();
return cb.apply(this, arguments);
};
}
}
return insertOriginal.apply(this, arguments);
};
//mongo _find 'Cursor' callback is the first parameter
let _findOriginal = mongo.Cursor.prototype._find;
mongo.Cursor.prototype._find = function() {
// console.log("Node Reaction Agent - MongoDB - Find");
if (arguments.length > 0) {
let trace = NodeReactionAgent.createTrace(library, "Find");
const cb = arguments[0];
if (typeof cb === "function") {
arguments[0] = function() {
if (trace) trace.end();
return cb.apply(this, arguments);
};
}
}
options.socketOptions && Object.keys(options.socketOptions).length > 0
? options.socketOptions
: options;
// Translate all the options to the mongodb-core ones
clonedOptions = translateOptions(clonedOptions, socketOptions);
// Build default client information
clonedOptions.clientInfo = this.clientInfo;
// Do we have an application specific string
if (options.appname) {
clonedOptions.clientInfo.application = { name: options.appname };
}
// Create the ReplSet
var coreTopology = new CReplSet(seedlist, clonedOptions);
// Listen to reconnect event
coreTopology.on('reconnect', function() {
self.emit('reconnect');
store.execute();
});
// Internal state
this.s = {
// Replicaset
coreTopology: coreTopology,
// Server capabilities
sCapabilities: null,
// Debug tag
tag: options.tag,
// Store options
name: name,
architecture: architecture,
version: release
},
platform: nodejsversion
}
// Build default client information
clonedOptions.clientInfo = this.clientInfo;
// Do we have an application specific string
if(options.appname) {
clonedOptions.clientInfo.application = { name: options.appname };
}
// Create the ReplSet
var replset = new CReplSet(seedlist, clonedOptions);
// Listen to reconnect event
replset.on('reconnect', function() {
self.emit('reconnect');
store.execute();
});
// Internal state
this.s = {
// Replicaset
replset: replset
// Server capabilities
, sCapabilities: null
// Debug tag
, tag: options.tag
// Store options
if(options.connectWithNoPrimary == true) {
finalOptions.secondaryOnlyConnectionAllowed = true;
}
// Add the non connection store
finalOptions.disconnectHandler = store;
// Translate the options
if(options.sslCA) finalOptions.ca = options.sslCA;
if(typeof options.sslValidate == 'boolean') finalOptions.rejectUnauthorized = options.sslValidate;
if(options.sslKey) finalOptions.key = options.sslKey;
if(options.sslCert) finalOptions.cert = options.sslCert;
if(options.sslPass) finalOptions.passphrase = options.sslPass;
// Create the ReplSet
var replset = new CReplSet(seedlist, finalOptions)
// Server capabilities
var sCapabilities = null;
// Add auth prbufferMaxEntriesoviders
replset.addAuthProvider('mongocr', new MongoCR());
// Listen to reconnect event
replset.on('reconnect', function() {
self.emit('reconnect');
store.execute();
});
// Internal state
this.s = {
// Replicaset
replset: replset
// Server capabilities
if(options.connectWithNoPrimary == true) {
finalOptions.secondaryOnlyConnectionAllowed = true;
}
// Add the non connection store
finalOptions.disconnectHandler = store;
// Translate the options
if(options.sslCA) finalOptions.ca = options.sslCA;
if(typeof options.sslValidate == 'boolean') finalOptions.rejectUnauthorized = options.sslValidate;
if(options.sslKey) finalOptions.key = options.sslKey;
if(options.sslCert) finalOptions.cert = options.sslCert;
if(options.sslPass) finalOptions.passphrase = options.sslPass;
// Create the ReplSet
var replset = new CReplSet(seedlist, finalOptions)
// Server capabilities
var sCapabilities = null;
// Add auth prbufferMaxEntriesoviders
replset.addAuthProvider('mongocr', new MongoCR());
// Listen to reconnect event
replset.on('reconnect', function() {
self.emit('reconnect');
store.execute();
});
// Internal state
this.s = {
// Replicaset
replset: replset
// Server capabilities
name: name,
architecture: architecture,
version: release
},
platform: nodejsversion
}
// Build default client information
clonedOptions.clientInfo = this.clientInfo;
// Do we have an application specific string
if(options.appname) {
clonedOptions.clientInfo.application = { name: options.appname };
}
// Create the ReplSet
var replset = new CReplSet(seedlist, clonedOptions);
// Listen to reconnect event
replset.on('reconnect', function() {
self.emit('reconnect');
store.execute();
});
// Internal state
this.s = {
// Replicaset
replset: replset
// Server capabilities
, sCapabilities: null
// Debug tag
, tag: options.tag
// Store options
name: name,
architecture: architecture,
version: release
},
platform: nodejsversion
}
// Build default client information
clonedOptions.clientInfo = this.clientInfo;
// Do we have an application specific string
if(options.appname) {
clonedOptions.clientInfo.application = { name: options.appname };
}
// Create the ReplSet
var replset = new CReplSet(seedlist, clonedOptions);
// Listen to reconnect event
replset.on('reconnect', function() {
self.emit('reconnect');
store.execute();
});
// Internal state
this.s = {
// Replicaset
replset: replset
// Server capabilities
, sCapabilities: null
// Debug tag
, tag: options.tag
// Store options
finalOptions.secondaryOnlyConnectionAllowed = true;
}
// Add the non connection store
finalOptions.disconnectHandler = store;
// Translate the options
if(options.sslCA) finalOptions.ca = options.sslCA;
if(typeof options.sslValidate == 'boolean') finalOptions.rejectUnauthorized = options.sslValidate;
if(options.sslKey) finalOptions.key = options.sslKey;
if(options.sslCert) finalOptions.cert = options.sslCert;
if(options.sslPass) finalOptions.passphrase = options.sslPass;
if(options.checkServerIdentity) finalOptions.checkServerIdentity = options.checkServerIdentity;
// Create the ReplSet
var replset = new CReplSet(seedlist, finalOptions)
// Server capabilities
var sCapabilities = null;
// Listen to reconnect event
replset.on('reconnect', function() {
self.emit('reconnect');
store.execute();
});
// Internal state
this.s = {
// Replicaset
replset: replset
// Server capabilities
, sCapabilities: null
// Debug tag