Socket
Socket
Sign inDemoInstall

mongodb-core

Package Overview
Dependencies
Maintainers
1
Versions
177
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongodb-core - npm Package Compare versions

Comparing version 1.2.20 to 1.2.21

7

HISTORY.md

@@ -0,1 +1,8 @@

1.2.21 11-07-2015
-----------------
- Hardened the checking for replicaset equality checks.
- OpReplay flag correctly set on Wire protocol query.
- Mongos load balancing added, introduced localThresholdMS to control the feature.
- Kerberos now a peerDependency, making it not install it by default in Node 5.0 or higher.
1.2.20 10-28-2015

@@ -2,0 +9,0 @@ -----------------

36

lib/connection/commands.js

@@ -71,3 +71,3 @@ "use strict";

this.slaveOk = false;
this.oplogReply = false;
this.oplogReplay = false;
this.noCursorTimeout = false;

@@ -100,10 +100,30 @@ this.awaitData = false;

var flags = 0;
if(this.tailable) flags |= OPTS_TAILABLE_CURSOR;
if(this.slaveOk) flags |= OPTS_SLAVE;
if(this.oplogReply) flags |= OPTS_OPLOG_REPLAY;
if(this.noCursorTimeout) flags |= OPTS_NO_CURSOR_TIMEOUT;
if(this.awaitData) flags |= OPTS_AWAIT_DATA;
if(this.exhaust) flags |= OPTS_EXHAUST;
if(this.partial) flags |= OPTS_PARTIAL;
if(this.tailable) {
flags |= OPTS_TAILABLE_CURSOR;
}
if(this.slaveOk) {
flags |= OPTS_SLAVE;
}
if(this.oplogReplay) {
flags |= OPTS_OPLOG_REPLAY;
}
if(this.noCursorTimeout) {
flags |= OPTS_NO_CURSOR_TIMEOUT;
}
if(this.awaitData) {
flags |= OPTS_AWAIT_DATA;
}
if(this.exhaust) {
flags |= OPTS_EXHAUST;
}
if(this.partial) {
flags |= OPTS_PARTIAL;
}
// If batchSize is different to self.numberToReturn

@@ -110,0 +130,0 @@ if(self.batchSize != self.numberToReturn) self.numberToReturn = self.batchSize;

@@ -381,3 +381,7 @@ "use strict";

Connection.prototype.destroy = function() {
if(this.connection) this.connection.destroy();
if(this.connection) {
this.connection.end();
this.connection.destroy();
}
this.destroyed = true;

@@ -384,0 +388,0 @@ }

@@ -220,2 +220,8 @@ "use strict";

this.connections = this.connections.slice(0, maxConnections);
if (this.index >= maxConnections){
// Go back to the beggining of the pool if capping connections
this.index = 0;
}
// Remove all listeners

@@ -222,0 +228,0 @@ for(var i = 0; i < connections.length; i++) {

@@ -59,3 +59,3 @@ "use strict";

var State = function(readPreferenceStrategies) {
var State = function(readPreferenceStrategies, localThresholdMS) {
// Internal state

@@ -66,2 +66,5 @@ this.s = {

, readPreferenceStrategies: readPreferenceStrategies
, lowerBoundLatency: Number.MAX_VALUE
, localThresholdMS: localThresholdMS
, index: 0
}

@@ -86,2 +89,7 @@ }

if(!found) this.s.connectedServers.push(server);
// Adjust lower bound
if(this.s.lowerBoundLatency > server.s.isMasterLatencyMS) {
this.s.lowerBoundLatency = server.s.isMasterLatencyMS;
}
}

@@ -163,13 +171,31 @@

State.prototype.pickServer = function(readPreference) {
var self = this;
readPreference = readPreference || ReadPreference.primary;
// Filter out the possible servers
var servers = this.s.connectedServers.filter(function(server) {
if((server.s.isMasterLatencyMS <= (self.s.lowerBoundLatency + self.s.localThresholdMS))
&& server.isConnected()) {
return true;
}
});
// console.log("####################################### servers :: " + servers.length)
// servers.forEach(function(x) {
// console.log(x.name)
// })
// Do we have a custom readPreference strategy, use it
if(this.s.readPreferenceStrategies != null && this.s.readPreferenceStrategies[readPreference] != null) {
return this.s.readPreferenceStrategies[readPreference].pickServer(connectedServers, readPreference);
return this.s.readPreferenceStrategies[readPreference].pickServer(servers, readPreference);
}
// No valid connections
if(this.s.connectedServers.length == 0) throw new MongoError("no mongos proxy available");
if(servers.length == 0) throw new MongoError("no mongos proxy available");
// Update index
this.s.index = (this.s.index + 1) % servers.length;
// Pick first one
return this.s.connectedServers[0];
return servers[this.s.index];
}

@@ -188,2 +214,3 @@

* @param {number} [options.keepAliveInitialDelay=0] Initial delay before TCP keep alive enabled
* @param {number} [options.localThresholdMS=15] Cutoff latency point in MS for MongoS proxy selection
* @param {boolean} [options.noDelay=true] TCP Connection no delay

@@ -241,2 +268,4 @@ * @param {number} [options.connectionTimeout=1000] TCP Connection timeout setting

, haInterval: options.haInterval || 5000
// localThresholdMS
, localThresholdMS: options.localThresholdMS || 15
// Have omitted fullsetup

@@ -251,2 +280,4 @@ , fullsetup: false

, bson: bson
// Pings
, pings: {}
// Default state

@@ -276,3 +307,3 @@ , state: DISCONNECTED

// Create a new state for the mongos
this.s.mongosState = new State(this.s.readPreferenceStrategies);
this.s.mongosState = new State(this.s.readPreferenceStrategies, this.s.localThresholdMS);

@@ -279,0 +310,0 @@ // BSON property (find a server and pass it along)

@@ -375,3 +375,3 @@ "use strict";

// Not in a known connection valid state
if(!ismaster.ismaster && !ismaster.secondary && !ismaster.arbiterOnly) {
if((!ismaster.ismaster && !ismaster.secondary && !ismaster.arbiterOnly) || !Array.isArray(ismaster.hosts)) {
// Remove the state

@@ -378,0 +378,0 @@ var result = self.remove(server);

@@ -652,12 +652,20 @@ "use strict";

// Get the server
var server = this.s.disconnectedServers.shift();
var server = self.s.disconnectedServers.shift();
// Set up the event handlers
server.once('error', errorHandlerTemp(this, this.s, 'error'));
server.once('close', errorHandlerTemp(this, this.s, 'close'));
server.once('timeout', errorHandlerTemp(this, this.s, 'timeout'));
server.once('connect', connectHandler(this, this.s));
server.once('error', errorHandlerTemp(self, self.s, 'error'));
server.once('close', errorHandlerTemp(self, self.s, 'close'));
server.once('timeout', errorHandlerTemp(self, self.s, 'timeout'));
server.once('connect', connectHandler(self, self.s));
// Attempt to connect
server.connect();
// Ensure we schedule the opening of new socket
// on separate ticks of the event loop
var execute = function(_server) {
// Attempt to connect
process.nextTick(function() {
_server.connect();
});
}
execute(server);
}

@@ -931,4 +939,13 @@ }

server.once('connect', connectHandler(self, state));
// Attempt to connect
server.connect();
// Ensure we schedule the opening of new socket
// on separate ticks of the event loop
var execute = function(_server) {
// Attempt to connect
process.nextTick(function() {
_server.connect();
});
}
execute(server);
}

@@ -1019,2 +1036,4 @@

processHosts(self, state, hosts);
} else if(err == null && !Array.isArray(ismaster.hosts)) {
server.destroy();
}

@@ -1296,4 +1315,7 @@

server.once('connect', connectHandler(self, state));
// Attempt to connect
server.connect();
process.nextTick(function() {
server.connect();
});
}

@@ -1305,2 +1327,4 @@

var found = false;
// If the server is a null value return false
if(server == null) return found;

@@ -1307,0 +1331,0 @@ // Remove any non used handlers

@@ -362,3 +362,4 @@ "use strict";

applyAuthentications(function() {
// Get the actual latency of the ismaster
var start = new Date().getTime();
// Execute an ismaster

@@ -371,2 +372,5 @@ self.command('system.$cmd', {ismaster:true}, function(err, r) {

// Set the latency for this instance
state.isMasterLatencyMS = new Date().getTime() - start;
// Set the current ismaster

@@ -543,2 +547,4 @@ if(!err) {

, pool: null
// Is master latency
, isMasterLatencyMS: 0
// Server details

@@ -705,3 +711,4 @@ , serverDetails: {

// Double check if we have a valid connection
if(!connection.isConnected()) {
// Checking that the connection exists to avoid an uncaught exception in case there is an issue with the pool
if(!(connection && connection.isConnected())) {
return callback(new MongoError(f("no connection available to server %s", self.name)));

@@ -1085,3 +1092,8 @@ }

if(typeof server == 'string') return server == this.name;
return server.name == this.name;
if(server && server.name) {
return server.name == this.name;
}
return false;
}

@@ -1088,0 +1100,0 @@

@@ -188,3 +188,3 @@ "use strict";

var operation = function(_server) {
var start = new Date();
var start = new Date();
// Execute ping against server

@@ -191,0 +191,0 @@ _server.command('system.$cmd', {ismaster:1}, function(err, r) {

@@ -148,2 +148,7 @@ "use strict";

// Does the cmd have a readPreference
if(cmd.readPreference) {
readPreference = cmd.readPreference;
}
// Ensure we have at least some options

@@ -247,2 +252,7 @@ options = options || {};

// Does the cmd have a readPreference
if(cmd.readPreference) {
readPreference = cmd.readPreference;
}
// Set empty options object

@@ -260,7 +270,2 @@ options = options || {}

// // We have a Mongos topology, check if we need to add a readPreference
// if(topology.type == 'mongos' && readPreference) {
// finalCmd['$readPreference'] = readPreference.toJSON();
// }
// Throw on majority readConcern passed in

@@ -267,0 +272,0 @@ if(cmd.readConcern && cmd.readConcern.level != 'local') {

@@ -138,2 +138,7 @@ "use strict";

// Does the cmd have a readPreference
if(cmd.readPreference) {
readPreference = cmd.readPreference;
}
// Ensure we have at least some options

@@ -221,8 +226,26 @@ options = options || {};

// Set up the option bits for wire protocol
if(typeof cmd.tailable == 'boolean') query.tailable = cmd.tailable;
if(typeof cmd.oplogReplay == 'boolean') query.oplogReplay = cmd.oplogReplay;
if(typeof cmd.noCursorTimeout == 'boolean') query.noCursorTimeout = cmd.noCursorTimeout;
if(typeof cmd.awaitData == 'boolean') query.awaitData = cmd.awaitData;
if(typeof cmd.exhaust == 'boolean') query.exhaust = cmd.exhaust;
if(typeof cmd.partial == 'boolean') query.partial = cmd.partial;
if(typeof cmd.tailable == 'boolean') {
query.tailable = cmd.tailable;
}
if(typeof cmd.oplogReplay == 'boolean') {
query.oplogReplay = cmd.oplogReplay;
}
if(typeof cmd.noCursorTimeout == 'boolean') {
query.noCursorTimeout = cmd.noCursorTimeout;
}
if(typeof cmd.awaitData == 'boolean') {
query.awaitData = cmd.awaitData;
}
if(typeof cmd.exhaust == 'boolean') {
query.exhaust = cmd.exhaust;
}
if(typeof cmd.partial == 'boolean') {
query.partial = cmd.partial;
}
// Return the query

@@ -239,2 +262,7 @@ return query;

// Does the cmd have a readPreference
if(cmd.readPreference) {
readPreference = cmd.readPreference;
}
// Set empty options object

@@ -252,7 +280,2 @@ options = options || {}

// // We have a Mongos topology, check if we need to add a readPreference
// if(topology.type == 'mongos' && readPreference) {
// finalCmd['$readPreference'] = readPreference.toJSON();
// }
// Serialize functions

@@ -259,0 +282,0 @@ var serializeFunctions = typeof options.serializeFunctions == 'boolean'

@@ -296,2 +296,7 @@ "use strict";

// Does the cmd have a readPreference
if(cmd.readPreference) {
readPreference = cmd.readPreference;
}
// Ensure we have at least some options

@@ -298,0 +303,0 @@ options = options || {};

{
"name": "mongodb-core",
"version": "1.2.20",
"version": "1.2.21",
"description": "Core MongoDB driver functionality, no bells and whistles and meant for integration not end applications",

@@ -29,10 +29,10 @@ "main": "index.js",

"rimraf": "2.2.6",
"mongodb-version-manager": "^0.8.10",
"mongodb-version-manager": "^1.x",
"co": "4.5.4"
},
"optionalDependencies": {
"peerDependencies": {
"kerberos": "~0.0"
},
"author": "Christian Kvalheim",
"license": "Apache 2.0",
"license": "Apache-2.0",
"bugs": {

@@ -39,0 +39,0 @@ "url": "https://github.com/christkv/mongodb-core/issues"

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc