Skip to content

Commit

Permalink
refactor: remove SKIP_SESSION aspect
Browse files Browse the repository at this point in the history
Now that we have disambiguated `maybePromise` from
`executeOperation`, there is no need to signal that an operation
should skip impliict sessions.
  • Loading branch information
mbroadst committed Feb 24, 2020
1 parent f6a8ceb commit 361bc1e
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 16 deletions.
4 changes: 0 additions & 4 deletions lib/operations/count.js
@@ -1,8 +1,6 @@
'use strict';

const Aspect = require('./operation').Aspect;
const buildCountCommand = require('./common_functions').buildCountCommand;
const defineAspects = require('./operation').defineAspects;
const OperationBase = require('./operation').OperationBase;

class CountOperation extends OperationBase {
Expand Down Expand Up @@ -67,6 +65,4 @@ class CountOperation extends OperationBase {
}
}

defineAspects(CountOperation, Aspect.SKIP_SESSION);

module.exports = CountOperation;
8 changes: 2 additions & 6 deletions lib/operations/execute_operation.js
Expand Up @@ -30,11 +30,7 @@ function executeOperation(topology, operation, callback) {
throw new TypeError('This method requires a valid operation instance');
}

if (
isUnifiedTopology(topology) &&
!operation.hasAspect(Aspect.SKIP_SESSION) &&
topology.shouldCheckForSessionSupport()
) {
if (isUnifiedTopology(topology) && topology.shouldCheckForSessionSupport()) {
return selectServerForSessionSupport(topology, operation, callback);
}

Expand All @@ -43,7 +39,7 @@ function executeOperation(topology, operation, callback) {
// The driver sessions spec mandates that we implicitly create sessions for operations
// that are not explicitly provided with a session.
let session, owner;
if (!operation.hasAspect(Aspect.SKIP_SESSION) && topology.hasSessionSupport()) {
if (topology.hasSessionSupport()) {
if (operation.session == null) {
owner = Symbol();
session = topology.startSession({ owner });
Expand Down
3 changes: 1 addition & 2 deletions lib/operations/find.js
Expand Up @@ -28,8 +28,7 @@ class FindOperation extends OperationBase {
defineAspects(FindOperation, [
Aspect.READ_OPERATION,
Aspect.RETRYABLE,
Aspect.EXECUTE_WITH_SELECTION,
Aspect.SKIP_SESSION
Aspect.EXECUTE_WITH_SELECTION
]);

module.exports = FindOperation;
4 changes: 1 addition & 3 deletions lib/operations/operation.js
Expand Up @@ -2,7 +2,6 @@

const Aspect = {
READ_OPERATION: Symbol('READ_OPERATION'),
SKIP_SESSION: Symbol('SKIP_SESSION'),
WRITE_OPERATION: Symbol('WRITE_OPERATION'),
RETRYABLE: Symbol('RETRYABLE'),
EXECUTE_WITH_SELECTION: Symbol('EXECUTE_WITH_SELECTION')
Expand All @@ -12,8 +11,7 @@ const Aspect = {
* This class acts as a parent class for any operation and is responsible for setting this.options,
* as well as setting and getting a session.
* Additionally, this class implements `hasAspect`, which determines whether an operation has
* a specific aspect, including `SKIP_SESSION` and other aspects to encode retryability
* and other functionality.
* a specific aspect.
*/
class OperationBase {
constructor(options) {
Expand Down
2 changes: 1 addition & 1 deletion lib/operations/remove_user.js
Expand Up @@ -47,6 +47,6 @@ class RemoveUserOperation extends CommandOperation {
}
}

defineAspects(RemoveUserOperation, [Aspect.WRITE_OPERATION, Aspect.SKIP_SESSIONS]);
defineAspects(RemoveUserOperation, Aspect.WRITE_OPERATION);

module.exports = RemoveUserOperation;

0 comments on commit 361bc1e

Please sign in to comment.