Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of https://github.com/christkv/node-mongodb-native

  • Loading branch information...
commit ad66f48b44e5b9f8543d4628ef729f40348c733e 2 parents 42e71b2 + cb84de7
@mrkurt mrkurt authored
View
2  HISTORY
@@ -1,3 +1,5 @@
+0.9.9.8 2012-04-12
+------------------
- _id=0 is being turned into an ObjectID (Issue #551)
- fix for error in GridStore write method (Issue #559)
- Fix for reading a GridStore from arbitrary, non-chunk aligned offsets, added test (Issue #563, https://github.com/subroutine)
View
4 dev/tools/build-docs.js
@@ -19,7 +19,9 @@ var apiClasses = [
{tag:"cursorstream", path:"./lib/mongodb/cursorstream.js"},
{tag:"gridstore", path:"./lib/mongodb/gridfs/gridstore.js"},
{tag:"readstream", path:"./lib/mongodb/gridfs/readstream.js"},
- {tag:"grid", path:"./lib/mongodb/gridfs/grid.js"}
+ {tag:"grid", path:"./lib/mongodb/gridfs/grid.js"},
+ {tag:"server", path:"./lib/mongodb/connection/server.js"},
+ {tag:"replset", path:"./lib/mongodb/connection/repl_set.js"}
];
// All test files
View
2  docs/sphinx-docs/conf.py
@@ -50,7 +50,7 @@
# The short X.Y version.
version = '0.9'
# The full version, including alpha/beta/rc tags.
-release = '0.9.9.7'
+release = '0.9.9.8'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
View
62 lib/mongodb/connection/repl_set.js
@@ -31,7 +31,7 @@ const STATE_ROLLBACK = 9;
* - **rs_name** {String}, the name of the replicaset to connect to.
* - **readPreference** {String}, the prefered read preference (Server.READ_PRIMARY, Server.READ_SECONDARY, Server.READ_SECONDARY_ONLY).
* - **read_secondary** {Boolean, deprecated}, allow reads from secondary.
- * - **strategy** {String}, selection strategy for reads choose between (ping and statistical)
+ * - **strategy** {String, default:null}, selection strategy for reads choose between (ping and statistical, default is round-robin)
*
* @class Represents a Replicaset Configuration
* @param {Array} list of server objects participating in the replicaset.
@@ -242,8 +242,14 @@ var ReplSet = exports.ReplSet = function(servers, options) {
this._replicasetTimeoutId = null;
};
+/**
+ * @ignore
+ */
inherits(ReplSet, EventEmitter);
+/**
+ * @ignore
+ */
// Allow setting the read preference at the replicaset level
ReplSet.prototype.setReadPreference = function(preference) {
// Set read preference
@@ -255,30 +261,51 @@ ReplSet.prototype.setReadPreference = function(preference) {
}
}
+/**
+ * @ignore
+ */
// Return the used state
ReplSet.prototype._isUsed = function() {
return this._used;
}
+/**
+ * @ignore
+ */
ReplSet.prototype.setTarget = function(target) {
this.target = target;
};
+/**
+ * @ignore
+ */
ReplSet.prototype.isConnected = function() {
// Return the state of the replicaset server
return this.primary != null && this._state.master != null && this._state.master.isConnected();
}
+/**
+ * @ignore
+ */
Server.prototype.isSetMember = function() {
return false;
}
+/**
+ * @ignore
+ */
ReplSet.prototype.isPrimary = function(config) {
return this.readSecondary && this.secondaries.length > 0 ? false : true;
}
+/**
+ * @ignore
+ */
ReplSet.prototype.isReadPrimary = ReplSet.prototype.isPrimary;
+/**
+ * @ignore
+ */
// Clean up dead connections
var cleanupConnections = ReplSet.cleanupConnections = function(connections, addresses, byTags) {
// Ensure we don't have entries in our set with dead connections
@@ -298,6 +325,9 @@ var cleanupConnections = ReplSet.cleanupConnections = function(connections, addr
}
}
+/**
+ * @ignore
+ */
var cleanupTags = ReplSet._cleanupTags = function(server, byTags) {
var serverTagKeys = Object.keys(server.tags);
// Iterate over all server tags and remove any instances for that tag that matches the current
@@ -328,6 +358,9 @@ var cleanupTags = ReplSet._cleanupTags = function(server, byTags) {
}
}
+/**
+ * @ignore
+ */
ReplSet.prototype.allServerInstances = function() {
var self = this;
// Close all the servers (concatenate entire list of servers first for ease)
@@ -358,6 +391,9 @@ ReplSet.prototype.allServerInstances = function() {
return allServers;
}
+/**
+ * @ignore
+ */
// Ensure no callback is left hanging when we have an error
var __executeAllCallbacksWithError = function(dbInstance, error) {
var keys = Object.keys(dbInstance._callBackStore._notReplied);
@@ -370,6 +406,9 @@ var __executeAllCallbacksWithError = function(dbInstance, error) {
}
}
+/**
+ * @ignore
+ */
ReplSet.prototype.connect = function(parent, options, callback) {
var self = this;
var dateStamp = new Date().getTime();
@@ -976,6 +1015,9 @@ ReplSet.prototype.connect = function(parent, options, callback) {
};
}
+/**
+ * @ignore
+ */
ReplSet.prototype.checkoutWriter = function() {
// Establish connection
var connection = this._state.master != null ? this._state.master.checkoutWriter() : null;
@@ -983,6 +1025,9 @@ ReplSet.prototype.checkoutWriter = function() {
return connection;
}
+/**
+ * @ignore
+ */
ReplSet.prototype.checkoutReader = function() {
var connection = null;
// If we have specified to read from a secondary server grab a random one and read
@@ -1033,6 +1078,9 @@ ReplSet.prototype.checkoutReader = function() {
return connection;
}
+/**
+ * @ignore
+ */
ReplSet.prototype.allRawConnections = function() {
// Neeed to build a complete list of all raw connections, start with master server
var allConnections = [];
@@ -1058,6 +1106,9 @@ ReplSet.prototype.allRawConnections = function() {
return allConnections;
}
+/**
+ * @ignore
+ */
ReplSet.prototype.enableRecordQueryStats = function(enable) {
// Set the global enable record query stats
this.recordQueryStats = enable;
@@ -1076,10 +1127,16 @@ ReplSet.prototype.enableRecordQueryStats = function(enable) {
}
}
+/**
+ * @ignore
+ */
ReplSet.prototype.disconnect = function(callback) {
this.close(callback);
}
+/**
+ * @ignore
+ */
ReplSet.prototype.close = function(callback) {
var self = this;
// Set server status as disconnected
@@ -1131,5 +1188,8 @@ ReplSet.prototype.close = function(callback) {
}
}
+/**
+ * @ignore
+ */
// Backward compatibility
exports.ReplSetServers = ReplSet;
View
91 lib/mongodb/connection/server.js
@@ -6,7 +6,24 @@ var Connection = require('./connection').Connection,
MongoReply = require("../responses/mongo_reply").MongoReply,
inherits = require('util').inherits;
-var Server = exports.Server = function(host, port, options) {
+/**
+ * Class representing a single MongoDB Server connection
+ *
+ * Options
+ * - **readPreference** {String, default:null}, set's the read preference (Server.READ_PRIMAR, Server.READ_SECONDARY_ONLY, Server.READ_SECONDARY)
+ * - **ssl** {Boolean, default:false}, use ssl connection (needs to have a mongod server with ssl support)
+ * - **slaveOk** {Boolean, default:false}, legacy option allowing reads from secondary, use **readPrefrence** instead.
+ * - **poolSize** {Number, default:1}, number of connections in the connection pool, set to 1 as default for legacy reasons.
+ * - **socketOptions** {Object, default:null}, an object containing socket options to use (noDelay:(boolean), keepAlive:(number), timeout:(number))
+ * - **logger** {Object, default:null}, an object representing a logger that you want to use, needs to support functions debug, log, error **({error:function(message, object) {}, log:function(message, object) {}, debug:function(message, object) {}})**.
+ * - **auto_reconnect** {Boolean, default:false}, reconnect on error.
+ *
+ * @class Represents a Server connection.
+ * @param {String} host the server host
+ * @param {Number} port the server port
+ * @param {Object} [options] optional options for insert command
+ */
+function Server(host, port, options) {
// Set up event emitter
EventEmitter.call(this);
// Set up Server instance
@@ -53,7 +70,7 @@ var Server = exports.Server = function(host, port, options) {
this.logger = this.options.logger != null
&& (typeof this.options.logger.debug == 'function')
&& (typeof this.options.logger.error == 'function')
- && (typeof this.options.logger.debug == 'function')
+ && (typeof this.options.logger.log == 'function')
? this.options.logger : {error:function(message, object) {}, log:function(message, object) {}, debug:function(message, object) {}};
// Just keeps list of events we allow
@@ -124,22 +141,28 @@ var Server = exports.Server = function(host, port, options) {
});
};
+/**
+ * @ignore
+ */
// Inherit simple event emitter
inherits(Server, EventEmitter);
// Read Preferences
Server.READ_PRIMARY = 'primary';
Server.READ_SECONDARY = 'secondary';
Server.READ_SECONDARY_ONLY = 'secondaryOnly';
-
// Always ourselves
Server.prototype.setReadPreference = function() {}
-// Return the used state
+/**
+ * @ignore
+ */
Server.prototype._isUsed = function() {
return this._used;
}
-// Server close function
+/**
+ * @ignore
+ */
Server.prototype.close = function(callback) {
// Remove all local listeners
this.removeAllListeners();
@@ -157,18 +180,30 @@ Server.prototype.close = function(callback) {
if(typeof callback === 'function') callback();
};
+/**
+ * @ignore
+ */
Server.prototype.isConnected = function() {
return this.connectionPool != null && this.connectionPool.isConnected();
}
+/**
+ * @ignore
+ */
Server.prototype.allServerInstances = function() {
return [this];
}
+/**
+ * @ignore
+ */
Server.prototype.isSetMember = function() {
return this['replicasetInstance'] != null;
}
+/**
+ * @ignore
+ */
Server.prototype.connect = function(dbInstance, options, callback) {
if('function' === typeof options) callback = options, options = {};
if(options == null) options = {};
@@ -486,7 +521,10 @@ Server.prototype.connect = function(dbInstance, options, callback) {
connectionPool.start();
}
-// Fire all the errors
+/**
+ * Fire all the errors
+ * @ignore
+ */
var _fireCallbackErrors = function(server, err) {
// Locate all the possible callbacks that need to return
for(var i = 0; i < server.dbInstances.length; i++) {
@@ -504,6 +542,9 @@ var _fireCallbackErrors = function(server, err) {
}
}
+/**
+ * @ignore
+ */
var _emitAcrossAllDbInstances = function(server, filterDb, event, message, object) {
// Emit close event across all db instances sharing the sockets
var allServerInstances = server.allServerInstances();
@@ -521,11 +562,17 @@ var _emitAcrossAllDbInstances = function(server, filterDb, event, message, objec
}
}
+/**
+ * @ignore
+ */
Server.prototype.allRawConnections = function() {
return this.connectionPool.getAllConnections();
}
-// Check if a writer can be provided
+/**
+ * Check if a writer can be provided
+ * @ignore
+ */
var canCheckoutWriter = function(self, read) {
// We cannot write to an arbiter or secondary server
if(self.isMasterDoc['arbiterOnly'] == true) {
@@ -540,6 +587,9 @@ var canCheckoutWriter = function(self, read) {
return null;
}
+/**
+ * @ignore
+ */
Server.prototype.checkoutWriter = function(read) {
if(read == true) return this.connectionPool.checkoutConnection();
// Check if are allowed to do a checkout (if we try to use an arbiter f.ex)
@@ -552,7 +602,10 @@ Server.prototype.checkoutWriter = function(read) {
}
}
-// Check if a reader can be provided
+/**
+ * Check if a reader can be provided
+ * @ignore
+ */
var canCheckoutReader = function(self) {
// We cannot write to an arbiter or secondary server
if(self.isMasterDoc['arbiterOnly'] == true) {
@@ -570,6 +623,9 @@ var canCheckoutReader = function(self) {
return null;
}
+/**
+ * @ignore
+ */
Server.prototype.checkoutReader = function() {
// Check if are allowed to do a checkout (if we try to use an arbiter f.ex)
var result = canCheckoutReader(this);
@@ -581,13 +637,18 @@ Server.prototype.checkoutReader = function() {
}
}
+/**
+ * @ignore
+ */
Server.prototype.enableRecordQueryStats = function(enable) {
this.recordQueryStats = enable;
}
-//
-// Internal statistics object used for calculating average and standard devitation on
-// running queries
+/**
+ * Internal statistics object used for calculating average and standard devitation on
+ * running queries
+ * @ignore
+ */
var RunningStats = function() {
var self = this;
this.m_n = 0;
@@ -622,6 +683,9 @@ var RunningStats = function() {
});
}
+/**
+ * @ignore
+ */
RunningStats.prototype.push = function(x) {
// Update the number of samples
this.m_n = this.m_n + 1;
@@ -638,3 +702,8 @@ RunningStats.prototype.push = function(x) {
this.m_oldS = this.m_newS;
}
}
+
+/**
+ * @ignore
+ */
+exports.Server = Server;
View
2  package.json
@@ -1,7 +1,7 @@
{ "name" : "mongodb"
, "description" : "A node.js driver for MongoDB"
, "keywords" : ["mongodb", "mongo", "driver", "db"]
-, "version" : "0.9.9-7"
+, "version" : "0.9.9-8"
, "author" : "Christian Amor Kvalheim <christkv@gmail.com>"
, "contributors" : [ "Aaron Heckmann",
"Christoph Pojer",
Please sign in to comment.
Something went wrong with that request. Please try again.