-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(unified-sdam): backport unified SDAM to master for v3.2.0
- Loading branch information
Showing
37 changed files
with
325 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
'use strict'; | ||
|
||
const Topology = require('mongodb-core').Topology; | ||
const ServerCapabilities = require('./topology_base').ServerCapabilities; | ||
const Cursor = require('../cursor'); | ||
const translateOptions = require('../utils').translateOptions; | ||
|
||
class NativeTopology extends Topology { | ||
constructor(servers, options) { | ||
options = options || {}; | ||
|
||
let clonedOptions = Object.assign( | ||
{}, | ||
{ | ||
cursorFactory: Cursor, | ||
reconnect: false, | ||
emitError: options.emitError, | ||
size: options.poolSize, | ||
monitorCommands: options.monitorCommands | ||
} | ||
); | ||
|
||
// Translate any SSL options and other connectivity options | ||
clonedOptions = translateOptions(clonedOptions, options); | ||
|
||
// 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); | ||
|
||
super(servers, clonedOptions); | ||
|
||
// Do we have an application specific string | ||
if (options.appname) { | ||
this.s.clientInfo.application = { name: options.appname }; | ||
} | ||
} | ||
|
||
capabilities() { | ||
if (this.s.sCapabilities) return this.s.sCapabilities; | ||
if (this.lastIsMaster() == null) return null; | ||
this.s.sCapabilities = new ServerCapabilities(this.lastIsMaster()); | ||
return this.s.sCapabilities; | ||
} | ||
} | ||
|
||
module.exports = NativeTopology; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.