Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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.1.16 to 1.1.17

4

HISTORY.md

@@ -0,1 +1,5 @@

1.1.17 03-16-2015
-----------------
- NODE-377, fixed issue where tags would correctly be checked on secondary and nearest to filter out eligible server candidates.
1.1.16 03-06-2015

@@ -2,0 +6,0 @@ -----------------

@@ -92,2 +92,5 @@ "use strict";

// If ssl not enabled
if(!this.ssl) this.rejectUnauthorized = false;
// Response options

@@ -94,0 +97,0 @@ this.responseOptions = {

@@ -735,2 +735,27 @@ "use strict";

//
// Filter serves by tags
var filterByTags = function(readPreference, servers) {
if(readPreference.tags == null) return servers;
var filteredServers = [];
var tags = readPreference.tags;
// Iterate over all the servers
for(var i = 0; i < servers.length; i++) {
var serverTag = servers[i].lastIsMaster().tags || {};
// Did we find the a matching server
var found = true;
// Check if the server is valid
for(var name in tags) {
if(serverTag[name] != tags[name]) found = false;
}
// Add to candidate list
if(found) filteredServers.push(servers[i]);
}
// Returned filtered servers
return filteredServers;
}
//
// Pick a server based on readPreference

@@ -765,4 +790,4 @@ var pickServer = function(self, s, readPreference) {

if(readPreference.equals(ReadPreference.secondary)) {
s.index = s.index + 1;
return s.replState.secondaries[s.index % s.replState.secondaries.length];
s.index = (s.index + 1) % s.replState.secondaries.length;
return s.replState.secondaries[s.index];
}

@@ -773,4 +798,9 @@

if(s.replState.secondaries.length > 0) {
s.index = s.index + 1;
return s.replState.secondaries[s.index % s.replState.secondaries.length];
// Apply tags if present
var servers = filterByTags(readPreference, s.replState.secondaries);
// If have a matching server pick one otherwise fall through to primary
if(servers.length > 0) {
s.index = (s.index + 1) % servers.length;
return servers[s.index];
}
}

@@ -786,4 +816,12 @@

if(s.replState.secondaries.length > 0) {
s.index = s.index + 1;
return s.replState.secondaries[s.index % s.replState.secondaries.length];
// Apply tags if present
var servers = filterByTags(readPreference, s.replState.secondaries);
// If have a matching server pick one otherwise fall through to primary
if(servers.length > 0) {
s.index = (s.index + 1) % servers.length;
return servers[s.index];
}
// Throw error a we have not valid secondary or primary servers
throw new MongoError("no secondary or primary server available");
}

@@ -790,0 +828,0 @@ }

@@ -54,2 +54,28 @@ "use strict";

/**
* @ignore
*/
var filterByTags = function(readPreference, servers) {
if(readPreference.tags == null) return servers;
var filteredServers = [];
var tags = readPreference.tags;
// Iterate over all the servers
for(var i = 0; i < servers.length; i++) {
var serverTag = servers[i].lastIsMaster().tags || {};
// Did we find the a matching server
var found = true;
// Check if the server is valid
for(var name in tags) {
if(serverTag[name] != tags[name]) found = false;
}
// Add to candidate list
if(found) filteredServers.push(servers[i]);
}
// Returned filtered servers
return filteredServers;
}
/**
* Pick a server

@@ -66,11 +92,19 @@ * @method

var seeds = {};
if(set.primary) seeds[set.primary.name] = true;
var servers = [];
if(set.primary) {
servers.push(set.primary);
}
for(var i = 0; i < set.secondaries.length; i++) {
seeds[set.secondaries[i].name] = true;
servers.push(set.secondaries[i]);
}
// Filter by tags
servers = filterByTags(readPreference, servers);
// Transform the list
var serverList = [];
for(var name in seeds) {
serverList.push({name: name, time: self.s.pings[name] || 0});
// for(var name in seeds) {
for(var i = 0; i < servers.length; i++) {
serverList.push({name: servers[i].name, time: self.s.pings[servers[i].name] || 0});
}

@@ -77,0 +111,0 @@

4

package.json
{
"name": "mongodb-core",
"version": "1.1.16",
"version": "1.1.17",
"description": "Core MongoDB driver functionality, no bells and whistles and meant for integration not end applications",

@@ -18,3 +18,3 @@ "main": "index.js",

"dependencies": {
"bson": "0.2.19",
"bson": "~0.2",
"mkdirp": "0.5.0",

@@ -21,0 +21,0 @@ "rimraf": "2.2.6"

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