Skip to content

Commit

Permalink
fix(topologies): unify topologies connect API (#1615)
Browse files Browse the repository at this point in the history
Eliminates the DB parameter from the `connect` call in replset
and mongos to unify the api with server.

BREAKING CHANGE:
Function signature for `.connect` method on replset and mongos has changed. You shouldn't have been using this anyway, but if you were, you only should pass `options` and `callback`.

Part of NODE-1089
  • Loading branch information
daprahamian committed Dec 18, 2017
1 parent 018c496 commit 0fb4658
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions lib/topologies/mongos.js
Expand Up @@ -209,7 +209,7 @@ class Mongos extends TopologyBase {
}

// Connect
connect(db, _options, callback) {
connect(_options, callback) {
var self = this;
if ('function' === typeof _options) (callback = _options), (_options = {});
if (_options == null) _options = {};
Expand All @@ -218,7 +218,8 @@ class Mongos extends TopologyBase {
self.s.options = _options;

// Update bufferMaxEntries
self.s.storeOptions.bufferMaxEntries = db.bufferMaxEntries;
self.s.storeOptions.bufferMaxEntries =
typeof _options.bufferMaxEntries === 'number' ? _options.bufferMaxEntries : -1;

// Error handler
var connectErrorHandler = function() {
Expand Down
5 changes: 3 additions & 2 deletions lib/topologies/replset.js
Expand Up @@ -236,7 +236,7 @@ class ReplSet extends TopologyBase {
}

// Connect method
connect(db, _options, callback) {
connect(_options, callback) {
var self = this;
if ('function' === typeof _options) (callback = _options), (_options = {});
if (_options == null) _options = {};
Expand All @@ -245,7 +245,8 @@ class ReplSet extends TopologyBase {
self.s.options = _options;

// Update bufferMaxEntries
self.s.storeOptions.bufferMaxEntries = db.bufferMaxEntries;
self.s.storeOptions.bufferMaxEntries =
typeof _options.bufferMaxEntries === 'number' ? _options.bufferMaxEntries : -1;

// Actual handler
var errorHandler = function(event) {
Expand Down

2 comments on commit 0fb4658

@sbrichardson
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dan,

What is the correct way to connect after upgrading from 3rc0 ?

I noticed this issue is open for docs also, thx

@mbroadst
Copy link
Member

@mbroadst mbroadst commented on 0fb4658 Dec 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sbr464 the buffer max entries are now picked up from the passed in options, rather than from a passed in Db instance. This change has simply made all three topology types consistent in this regard.

Also, generally you shouldn't be connecting this way. This is the connect method directly on a topology instance, and most cases (99%) should simply be using MongoClient.connect

Please sign in to comment.