Skip to content

Commit 361bc1e

Browse files
committed
refactor: remove SKIP_SESSION aspect
Now that we have disambiguated `maybePromise` from `executeOperation`, there is no need to signal that an operation should skip impliict sessions.
1 parent f6a8ceb commit 361bc1e

File tree

5 files changed

+5
-16
lines changed

5 files changed

+5
-16
lines changed

lib/operations/count.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
'use strict';
22

3-
const Aspect = require('./operation').Aspect;
43
const buildCountCommand = require('./common_functions').buildCountCommand;
5-
const defineAspects = require('./operation').defineAspects;
64
const OperationBase = require('./operation').OperationBase;
75

86
class CountOperation extends OperationBase {
@@ -67,6 +65,4 @@ class CountOperation extends OperationBase {
6765
}
6866
}
6967

70-
defineAspects(CountOperation, Aspect.SKIP_SESSION);
71-
7268
module.exports = CountOperation;

lib/operations/execute_operation.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,7 @@ function executeOperation(topology, operation, callback) {
3030
throw new TypeError('This method requires a valid operation instance');
3131
}
3232

33-
if (
34-
isUnifiedTopology(topology) &&
35-
!operation.hasAspect(Aspect.SKIP_SESSION) &&
36-
topology.shouldCheckForSessionSupport()
37-
) {
33+
if (isUnifiedTopology(topology) && topology.shouldCheckForSessionSupport()) {
3834
return selectServerForSessionSupport(topology, operation, callback);
3935
}
4036

@@ -43,7 +39,7 @@ function executeOperation(topology, operation, callback) {
4339
// The driver sessions spec mandates that we implicitly create sessions for operations
4440
// that are not explicitly provided with a session.
4541
let session, owner;
46-
if (!operation.hasAspect(Aspect.SKIP_SESSION) && topology.hasSessionSupport()) {
42+
if (topology.hasSessionSupport()) {
4743
if (operation.session == null) {
4844
owner = Symbol();
4945
session = topology.startSession({ owner });

lib/operations/find.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ class FindOperation extends OperationBase {
2828
defineAspects(FindOperation, [
2929
Aspect.READ_OPERATION,
3030
Aspect.RETRYABLE,
31-
Aspect.EXECUTE_WITH_SELECTION,
32-
Aspect.SKIP_SESSION
31+
Aspect.EXECUTE_WITH_SELECTION
3332
]);
3433

3534
module.exports = FindOperation;

lib/operations/operation.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
const Aspect = {
44
READ_OPERATION: Symbol('READ_OPERATION'),
5-
SKIP_SESSION: Symbol('SKIP_SESSION'),
65
WRITE_OPERATION: Symbol('WRITE_OPERATION'),
76
RETRYABLE: Symbol('RETRYABLE'),
87
EXECUTE_WITH_SELECTION: Symbol('EXECUTE_WITH_SELECTION')
@@ -12,8 +11,7 @@ const Aspect = {
1211
* This class acts as a parent class for any operation and is responsible for setting this.options,
1312
* as well as setting and getting a session.
1413
* Additionally, this class implements `hasAspect`, which determines whether an operation has
15-
* a specific aspect, including `SKIP_SESSION` and other aspects to encode retryability
16-
* and other functionality.
14+
* a specific aspect.
1715
*/
1816
class OperationBase {
1917
constructor(options) {

lib/operations/remove_user.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,6 @@ class RemoveUserOperation extends CommandOperation {
4747
}
4848
}
4949

50-
defineAspects(RemoveUserOperation, [Aspect.WRITE_OPERATION, Aspect.SKIP_SESSIONS]);
50+
defineAspects(RemoveUserOperation, Aspect.WRITE_OPERATION);
5151

5252
module.exports = RemoveUserOperation;

0 commit comments

Comments
 (0)