summaryrefslogtreecommitdiff
path: root/src/mongo/shell/session.js
diff options
context:
space:
mode:
authorJason Carey <jcarey@argv.me>2017-09-29 12:18:53 -0400
committerJason Carey <jcarey@argv.me>2017-10-03 16:50:12 -0400
commitf23002e965d29158505575d09432faf403efcb56 (patch)
tree5794d12d94376b7cc55186862e4a43d850cab4d5 /src/mongo/shell/session.js
parent8a4b356682d9a3d39049c2d51ac4f10ed1e6d07e (diff)
downloadmongo-f23002e965d29158505575d09432faf403efcb56.tar.gz
SERVER-30848 make shell getMores use sessions
The shell should attach the logical session used to initiate cursors (via find or aggregate) and use it for successive getMores.
Diffstat (limited to 'src/mongo/shell/session.js')
-rw-r--r--src/mongo/shell/session.js48
1 files changed, 46 insertions, 2 deletions
diff --git a/src/mongo/shell/session.js b/src/mongo/shell/session.js
index aa1d56afb01..2df6468c729 100644
--- a/src/mongo/shell/session.js
+++ b/src/mongo/shell/session.js
@@ -2,7 +2,7 @@
* Implements the sessions api for the shell.
*/
var {
- DriverSession, SessionOptions, _DummyDriverSession,
+ DriverSession, SessionOptions, _DummyDriverSession, _DelegatingDriverSession,
} = (function() {
"use strict";
@@ -278,7 +278,7 @@ var {
if (!cmdObjUnwrapped.hasOwnProperty("lsid")) {
cmdObjUnwrapped.lsid = this.handle.getId();
- // We consider the session to still be in used by the client any time the session id
+ // We consider the session to still be in use by the client any time the session id
// is injected into the command object as part of making a request.
updateLastUsed();
}
@@ -414,6 +414,10 @@ var {
return client;
};
+ this._getSessionAwareClient = function _getSessionAwareClient() {
+ return this._serverSession.client;
+ };
+
this.getOptions = function getOptions() {
return _options;
};
@@ -457,6 +461,45 @@ var {
},
});
+ function DelegatingDriverSession(client, originalSession) {
+ this._serverSession = originalSession._serverSession;
+ Object.defineProperty(this, "_operationTime", {
+ get: function() {
+ return originalSession._operationTime;
+ },
+ set: function(operationTime) {
+ originalSession._operationTime = operationTime;
+ },
+ });
+ const sessionAwareClient = new SessionAwareClient(client);
+
+ this.getClient = function() {
+ return client;
+ };
+
+ this._getSessionAwareClient = function() {
+ return sessionAwareClient;
+ };
+
+ this.getOptions = function() {
+ return originalSession.getOptions();
+ };
+
+ this.getDatabase = function(dbName) {
+ const db = client.getDB(dbName);
+ db._session = this;
+ return db;
+ };
+
+ this.hasEnded = function() {
+ return originalSession.hasEnded();
+ };
+
+ this.endSession = function() {
+ return originalSession.endSession();
+ };
+ }
+
const DummyDriverSession = makeDriverSessionConstructor({
createServerSession: function createServerSession(client) {
return {
@@ -488,5 +531,6 @@ var {
DriverSession: DriverSession,
SessionOptions: SessionOptions,
_DummyDriverSession: DummyDriverSession,
+ _DelegatingDriverSession: DelegatingDriverSession,
};
})();